:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --ink: #1a2233;
  --muted: #6b7488;
  --line: #e6e9f2;
  --brand: #5a4ff3;
  --green: #17a673;
  --red: #e5484d;
  --shadow: 0 6px 24px rgba(30, 40, 90, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--brand); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 650; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #b9f6ca; box-shadow: 0 0 0 4px rgba(255,255,255,.15); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.synced { font-size: 13px; opacity: .9; }
.btn {
  background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.3);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600;
}
.btn:hover { background: rgba(255,255,255,.26); }
.btn:disabled { opacity: .55; cursor: default; }

.banner { padding: 10px 24px; font-size: 14px; }
.banner.err { background: #fdecee; color: var(--red); border-bottom: 1px solid #f6c9cc; }
.banner.info { background: #eef1ff; color: var(--brand); border-bottom: 1px solid #d9defb; }
.hidden { display: none !important; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px; }

.hero { display: grid; grid-template-columns: 260px 1fr; gap: 18px; margin-bottom: 22px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } }
.hero-total {
  background: linear-gradient(135deg, #5a4ff3, #7b6cff); color: #fff;
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow);
}
.hero-label { font-size: 13px; opacity: .85; }
.hero-value { font-size: 40px; font-weight: 750; margin-top: 6px; letter-spacing: -1px; }
.hero-meta { font-size: 13px; opacity: .85; margin-top: 8px; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 620px) { .cards { grid-template-columns: repeat(2, 1fr); } }
.card { background: var(--panel); border-radius: 14px; padding: 16px; box-shadow: var(--shadow); }
.card-title { font-size: 13px; color: var(--muted); font-weight: 600; }
.card-profit { font-size: 24px; font-weight: 700; margin-top: 10px; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; background: #e9ecf6; padding: 4px; border-radius: 10px; }
.tab { border: none; background: transparent; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab.active { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.pill { background: var(--brand); color: #fff; border-radius: 20px; padding: 1px 8px; font-size: 12px; margin-left: 4px; }
.search { flex: 1; min-width: 200px; max-width: 320px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; background: #fff; }

.table-wrap { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); overflow-x: auto; }
.nowrap { white-space: nowrap; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--green); margin-left: 6px; vertical-align: middle; animation: livepulse 1.4s infinite; }
@keyframes livepulse { 0% { opacity: 1; box-shadow: 0 0 0 0 rgba(23,166,115,.5); } 70% { opacity: .55; box-shadow: 0 0 0 6px rgba(23,166,115,0); } 100% { opacity: 1; } }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 13px 16px; font-size: 14px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl tbody tr:hover { background: #fafbff; }
.tbl tbody tr:last-child td { border-bottom: none; }
.unnamed-row { background: #f7f8fc; font-style: italic; }
.friend-row { background: #fff8ec; }
.friend-row:hover { background: #fff3dd; }
.friend-tag { display: inline-block; background: #ffd980; color: #6b4e00; border-radius: 6px; font-size: 11px; padding: 1px 6px; margin-left: 6px; font-weight: 700; }
.pos { color: var(--green); font-weight: 650; }
.neg { color: var(--red); font-weight: 650; }
.acct { font-weight: 600; }
.muted { color: var(--muted); }
.bookies { color: var(--muted); font-size: 12px; }
.conn { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 7px; vertical-align: middle; }
.conn.on { background: var(--green); }
.conn.off { background: #cdd3e0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* login */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef0fb, #f6f7fc); }
.login-card { background: #fff; padding: 32px; border-radius: 16px; box-shadow: var(--shadow); width: 340px; display: flex; flex-direction: column; gap: 12px; }
.center { text-align: center; justify-content: center; }
.brand.center { color: var(--brand); }
.brand.center .dot { background: var(--brand); }
.input { padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; width: 100%; background: #fff; }
.input.sm { padding: 8px 11px; font-size: 13px; }
.input.grow { flex: 1; }
.input.prefix { width: 70px; text-align: center; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #4a3fe0; }
.btn.full { width: 100%; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.err-text { color: var(--red); font-size: 13px; }
.who { font-size: 13px; opacity: .95; padding-left: 6px; border-left: 1px solid rgba(255,255,255,.3); }

/* layout */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }
.section-h { margin: 18px 0 10px; font-size: 15px; }
.panel { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 16px 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.panel-head.mt { margin-top: 18px; }
.panel-head h3 { margin: 0; font-size: 15px; }

/* split card */
.split-card { background: var(--panel); border-radius: 14px; box-shadow: var(--shadow); padding: 18px; }
.split-flow { border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 12px; }
.flow-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 14px; }
.flow-row.muted { color: var(--muted); }
.flow-row.total { border-top: 1px dashed var(--line); margin-top: 4px; padding-top: 8px; font-weight: 700; }
.split-shares { display: flex; gap: 12px; }
.share { flex: 1; background: #f5f6fc; border-radius: 10px; padding: 12px; text-align: center; }
.share.big { background: #ecfdf5; }
.share-label { font-size: 12px; color: var(--muted); }
.share-val { font-size: 22px; font-weight: 750; margin-top: 4px; }
.friend-hero { grid-template-columns: 260px 1fr; }

/* mini table + forms */
.tbl.mini th, .tbl.mini td { padding: 8px 10px; font-size: 13px; }
.link-btn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.exp-form { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 8px; }
.row .input { flex: 1; }
.field { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 14px; }
.field .input { max-width: 120px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
