:root {
  --bg: #0f1115;
  --card: #181b22;
  --card2: #20242e;
  --text: #e8eaed;
  --muted: #9aa0aa;
  --line: #272b34;
  --up: #f6465d;     /* 红涨 */
  --down: #2ebd85;   /* 绿跌 */
  --accent: #4c8dff;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 16px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }

/* 登录 */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border: 1px solid var(--line); border-radius: 16px; padding: 28px 22px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; text-align: center; }
.login-card .sub { margin: 0 0 8px; color: var(--muted); font-size: 13px; text-align: center; }
.login-card input {
  background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 13px 14px; font-size: 16px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button[type=submit] {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 13px; font-size: 16px; font-weight: 600; margin-top: 4px;
}
.err { color: var(--up); font-size: 13px; min-height: 18px; text-align: center; }

/* 顶栏 */
.app { max-width: 640px; margin: 0 auto; padding: 0 12px 40px; }
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 2px 10px;
}
.status { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.open { background: var(--down); box-shadow: 0 0 8px var(--down); }
.dot.closed { background: var(--muted); }
.dot.err { background: var(--up); }
.actions { display: flex; gap: 8px; }
.ghost {
  background: var(--card2); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 13px;
}
.updated { color: var(--muted); font-size: 12px; padding: 0 2px 8px; }

/* 卡片 */
.cards { display: flex; flex-direction: column; gap: 12px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; transition: background .15s;
}
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.fund-name { font-size: 16px; font-weight: 600; }
.fund-code { color: var(--muted); font-size: 12px; margin-left: 6px; font-weight: 400; }
.est-pct { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-sub { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.card-sub b { color: var(--text); font-weight: 600; }
.flash { animation: flash .6s ease; }
@keyframes flash { 0% { background: var(--card2); } 100% { background: var(--card); } }

.up { color: var(--up); }
.down { color: var(--down); }
.flat { color: var(--muted); }

.expand-btn {
  margin-top: 10px; background: none; border: 0; color: var(--accent);
  font-size: 13px; padding: 2px 0;
}
.holdings { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.hold-row {
  display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px;
  padding: 6px 0; font-size: 13px; align-items: center;
}
.hold-row .h-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hold-row .h-w { color: var(--muted); font-variant-numeric: tabular-nums; }
.hold-row .h-c { font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }
.hold-row .h-ah { font-variant-numeric: tabular-nums; font-size: 11px; opacity: 0.85; min-width: 76px; text-align: right; }

.empty { color: var(--muted); text-align: center; padding: 60px 20px; font-size: 14px; }
.disclaimer { color: var(--muted); font-size: 11px; text-align: center; margin-top: 24px; line-height: 1.6; }

/* 弹层 */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; z-index: 20; }
.modal-card {
  width: 100%; max-width: 640px; margin: 0 auto; background: var(--card);
  border-radius: 16px 16px 0 0; max-height: 80vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--line); font-weight: 600;
}
.add-bar { display: flex; gap: 8px; padding: 12px 16px 4px; }
.add-bar input {
  flex: 1; background: var(--card2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 11px 12px; font-size: 16px; outline: none;
}
.add-bar input:focus { border-color: var(--accent); }
.add-bar button {
  background: var(--accent); color: #fff; border: 0; border-radius: 10px;
  padding: 0 18px; font-size: 15px; font-weight: 600;
}
#add-err { padding: 0 16px; text-align: left; }
.catalog { overflow-y: auto; padding: 6px 8px 20px; }
.cat-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 10px; border-bottom: 1px solid var(--line);
}
.cat-info { display: flex; flex-direction: column; }
.cat-name { font-size: 15px; }
.cat-code { font-size: 12px; color: var(--muted); }
.cat-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }
