:root {
  --purple: #667eea;
  --purple2: #764ba2;
  --ink: #1d2433;
  --muted: #7d8598;
  --line: #e9edf5;
  --bg: #f4f6fb;
  --card: #fff;
  --green: #0f9f6e;
  --red: #d94348;
  --gray: #8b93a5;
  --shadow: 0 6px 24px rgba(40, 50, 90, .07);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  font-family: "Microsoft YaHei UI", "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }
a { color: var(--purple); }

.login-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, rgba(102,126,234,.22), transparent 40%),
              radial-gradient(circle at 90% 90%, rgba(118,75,162,.18), transparent 45%),
              linear-gradient(135deg, #f7f8ff, #f1f3fb);
}
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 20px; padding: 30px 26px; box-shadow: 0 24px 60px rgba(40, 50, 100, .14); }
.login-logo { width: 62px; height: 62px; border-radius: 16px; display: block; margin: 0 auto 14px; box-shadow: 0 8px 20px rgba(102,126,234,.25); }
.login-card h1 { text-align: center; font-size: 24px; letter-spacing: -.5px; }
.login-sub { text-align: center; color: var(--muted); font-size: 11px; margin: 6px 0 22px; }
.login-card label { display: block; font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.login-card input { width: 100%; height: 44px; margin-top: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fbfcff; outline: none; }
.login-card input:focus { border-color: #aeb9f8; box-shadow: 0 0 0 3px rgba(102,126,234,.1); }
.login-foot { text-align: center; font-size: 10px; color: #a3aabb; margin-top: 18px; }
.error { color: var(--red); font-size: 11px; margin-top: 10px; min-height: 16px; }

.app-view { min-height: 100vh; padding-bottom: 78px; }
.topbar {
  height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  background: linear-gradient(118deg, #667eea, #764ba2); color: #fff; position: sticky; top: 0; z-index: 20;
  box-shadow: 0 4px 18px rgba(80, 90, 170, .18);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand b { display: block; font-size: 14px; letter-spacing: .4px; }
.brand span { display: block; font-size: 9px; opacity: .72; margin-top: 1px; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #7cf5c0; box-shadow: 0 0 0 3px rgba(124,245,192,.16); }
.dot.off { background: #ffd48a; box-shadow: 0 0 0 3px rgba(255,212,138,.16); }
.icon-btn { color: #fff; font-size: 12px; padding: 6px 8px; border-radius: 6px; background: rgba(255,255,255,.12); }
.icon-btn:hover { background: rgba(255,255,255,.2); }

main { max-width: 1120px; margin: 0 auto; padding: 16px; }
.view { display: none; }
.view.active { display: block; animation: fade .22s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.hero {
  background: linear-gradient(120deg, #fff, #f7f6ff); border: 1px solid #e9e8fb; border-radius: 16px;
  padding: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  box-shadow: var(--shadow);
}
.eyebrow { font-size: 8px; font-weight: 800; letter-spacing: 1.6px; color: #6d78d8; }
.hero h1 { font-size: 21px; margin: 5px 0 5px; letter-spacing: -.4px; }
.hero p { font-size: 11px; color: var(--muted); line-height: 1.6; }
.hero-actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border-radius: 9px; font-size: 12px; font-weight: 600; transition: .18s; white-space: nowrap; }
.btn.primary { background: linear-gradient(135deg, #667eea, #764ba2); color: #fff; box-shadow: 0 4px 12px rgba(102,126,234,.25); }
.btn.primary:active { transform: translateY(1px); }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: #596173; }
.btn.block { width: 100%; height: 44px; }
.btn:disabled { opacity: .55; cursor: wait; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 3px 12px rgba(40,50,90,.04); }
.stat span { font-size: 9.5px; color: var(--muted); }
.stat b { display: block; font-size: 20px; margin-top: 4px; letter-spacing: -.5px; }
.stat em { display: block; font-style: normal; font-size: 8.5px; color: #a3aabb; margin-top: 2px; }

.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 9px; }
.section-head h2 { font-size: 13px; }
.link { font-size: 10.5px; color: var(--purple); }
.muted { color: var(--muted); font-size: 9.5px; line-height: 1.6; }

.report-list { display: flex; flex-direction: column; gap: 8px; }
.report-item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; box-shadow: 0 3px 12px rgba(40,50,90,.04); cursor: pointer; }
.report-item:hover { border-color: #d8ddf8; }
.report-item .ri-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.report-item b { font-size: 12px; }
.report-item .tag { font-size: 8.5px; padding: 2px 6px; border-radius: 4px; background: #f1f3f8; color: #7b8496; }
.report-item p { font-size: 10px; color: var(--muted); line-height: 1.55; margin-top: 5px; }
.report-item .meta { font-size: 8.5px; color: #a3aabb; margin-top: 5px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 13px; padding: 14px; margin-bottom: 10px; box-shadow: 0 3px 12px rgba(40,50,90,.04); }
.card h3 { font-size: 13px; margin-bottom: 6px; }
.kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed #f0f2f7; font-size: 11px; }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; text-align: right; }

.add-row { display: flex; gap: 7px; margin-bottom: 12px; }
.add-row input { flex: 1; min-width: 0; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px; background: #fff; outline: none; }
.add-row input:focus { border-color: #aeb9f8; }
.watch-input-wrap { position: relative; flex: 1; min-width: 0; }
.watch-input-wrap input { width: 100%; }
.suggest {
  position: absolute; left: 0; right: 0; top: 44px; z-index: 50; background: #fff;
  border: 1px solid #d6dcf2; border-radius: 10px; box-shadow: 0 16px 38px rgba(37,47,80,.2);
  padding: 5px; max-height: 260px; overflow-y: auto;
}
.suggest-item { display: flex; align-items: center; gap: 8px; padding: 9px 8px; border-radius: 7px; cursor: pointer; border-left: 3px solid transparent; }
.suggest-item:hover, .suggest-item.active { background: #eef1ff; border-left-color: #667eea; }
.suggest-item .sc { font-family: Consolas, monospace; font-size: 10px; color: #7b84e0; width: 46px; flex-shrink: 0; }
.suggest-item .sn { font-size: 12px; color: #2a3142; font-weight: 600; }
.suggest-item .st { margin-left: auto; font-size: 8.5px; color: #a2a9b8; }
.watch-list { display: flex; flex-direction: column; gap: 8px; }
.watch-item { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: 0 3px 12px rgba(40,50,90,.04); }
.watch-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.watch-top b { font-size: 13px; }
.watch-top .code { font-size: 9px; color: #9aa1b3; margin-left: 5px; }
.watch-actions { display: flex; gap: 5px; }
.tiny { font-size: 9px; padding: 4px 8px; border-radius: 5px; background: #f4f6fb; color: #6f778a; }
.tiny.danger { color: var(--red); background: #fff1f1; }
.pos-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; margin-top: 9px; align-items: end; }
.pos-row label { font-size: 8.5px; color: #9aa1b3; }
.pos-row input { width: 100%; height: 32px; border: 1px solid var(--line); border-radius: 7px; padding: 0 8px; margin-top: 3px; background: #fbfcff; }
.pos-save { height: 32px; padding: 0 10px; border-radius: 7px; background: #eef1ff; color: #5b67d8; font-size: 10px; font-weight: 600; }

label { display: block; font-size: 10.5px; color: var(--muted); margin-bottom: 10px; }
label input { display: block; width: 100%; height: 38px; margin-top: 5px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fbfcff; outline: none; }
label input:focus { border-color: #aeb9f8; box-shadow: 0 0 0 3px rgba(102,126,234,.08); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.switch input { width: 34px; height: 19px; appearance: none; background: #dfe3ed; border-radius: 12px; position: relative; transition: .18s; flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(30,40,70,.2); transition: .18s; }
.switch input:checked { background: linear-gradient(135deg,#667eea,#764ba2); }
.switch input:checked::after { left: 17px; }
.row { display: flex; gap: 7px; flex-wrap: wrap; }
.log { background: #1d2433; color: #b9e4d1; border-radius: 8px; padding: 10px; font-family: Consolas, monospace; font-size: 9px; line-height: 1.6; max-height: 300px; overflow: auto; white-space: pre-wrap; }

.bottom-nav { position: fixed; left: 0; right: 0; bottom: 0; height: 62px; display: flex; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(10px); z-index: 30; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: #9aa1b3; font-size: 9px; }
.bottom-nav button span { font-size: 17px; line-height: 1; }
.bottom-nav button.active { color: var(--purple); font-weight: 700; }

.modal { position: fixed; inset: 0; z-index: 80; background: rgba(20,26,45,.45); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-card { width: 100%; max-width: 720px; max-height: 92vh; background: #fff; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 14px; }
.modal-head .icon-btn { background: #f4f6fb; color: #6f778a; }
.modal-body { padding: 14px 16px 24px; overflow-y: auto; }
.report-modal .modal-body { padding-bottom: 30px; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%) translateY(10px); background: #262d42; color: #fff; padding: 9px 14px; border-radius: 8px; font-size: 11px; opacity: 0; pointer-events: none; transition: .25s; z-index: 100; max-width: 88vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #9b2c33; }

.stock-report { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.stock-report h4 { font-size: 14px; }
.stock-report .price { font-size: 11px; color: var(--muted); margin: 3px 0 7px; }
.advice-chips { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.chip { border-radius: 8px; padding: 7px 8px; background: #fafbfe; border: 1px solid #f0f2f7; }
.chip .cl { display: flex; justify-content: space-between; font-size: 9px; color: #8b93a5; }
.chip .stars { font-size: 14px; letter-spacing: .8px; margin-top: 4px; }
.chip.buy { background: #f7fdfa; border-color: #d8f2e6; }
.chip.buy .stars { color: var(--green); }
.chip.watch .stars { color: var(--gray); }
.chip.sell { background: #fff8f8; border-color: #f7dada; }
.chip.sell .stars { color: var(--red); }
.chip p { font-size: 8.5px; color: #9aa1b3; line-height: 1.5; margin-top: 4px; }
.hold-box { margin-top: 8px; padding: 8px 9px; border-radius: 8px; background: #fbfcff; border: 1px solid #eef1f8; font-size: 9.5px; color: #7d8598; line-height: 1.6; }
.hold-box b { color: #4d5568; }
.risk-line { font-size: 8.5px; color: #9aa1b3; margin-top: 5px; }

@media (min-width: 720px) {
  main { padding: 22px 24px; }
  .hero { padding: 22px 24px; }
  .hero-actions { flex-direction: row; }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .advice-chips { grid-template-columns: repeat(4, 1fr); }
  .bottom-nav { max-width: 620px; margin: 0 auto; border-radius: 16px 16px 0 0; border: 1px solid var(--line); border-bottom: 0; }
  .modal { align-items: center; padding: 24px; }
  .modal-card { border-radius: 18px; }
}
