:root {
	--bg: #0d1117; --card: #161b22; --line: #262d37; --text: #e6edf3; --muted: #8b949e;
	--up: #3fb950; --down: #f85149; --accent: #58a6ff; --live: #f0883e;
	color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--bg); color: var(--text);
	font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 760px; margin: 0 auto; padding: 12px 16px 48px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 0 8px; font-weight: 600; }
button { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.up { color: var(--up); }
.down { color: var(--down); }
.num { font-variant-numeric: tabular-nums; }

.top { position: sticky; top: 0; z-index: 5; background: rgba(13, 17, 23, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.top-row { max-width: 760px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 12px; font-size: 13px; min-width: 0; }
.top-right form { margin: 0; }
.link { background: none; border: 0; padding: 6px 0; color: var(--accent); cursor: pointer; white-space: nowrap; }

.notice { background: #3d2a12; border: 1px solid #6b4a1d; color: #f2cc8f; padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }

.summary { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.label { font-size: 12px; color: var(--muted); }
.big { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 12px; margin-top: 14px; }
.stat { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

.filters { display: flex; gap: 8px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.filters::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-size: 14px; min-height: 40px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 600; }
.chip .count { opacity: .65; margin-left: 4px; }

.cards { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card.settled { opacity: .7; }
.card-head { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; width: 100%; padding: 12px; background: none; border: 0; text-align: left; cursor: pointer; }
.icon { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--line); }
.mid { min-width: 0; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.sub { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.pill { display: inline-block; background: #1f2a3a; color: #a5c8ff; border-radius: 6px; padding: 1px 7px; font-size: 12px; font-weight: 600; margin-right: 6px; }
.badge { display: inline-block; border-radius: 6px; padding: 1px 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-right: 6px; }
.badge.live { background: rgba(240, 136, 62, .18); color: var(--live); }
.badge.won { background: rgba(63, 185, 80, .18); color: var(--up); }
.badge.lost { background: rgba(248, 81, 73, .18); color: var(--down); }
.badge.final { background: var(--line); color: var(--muted); }
.right { text-align: right; white-space: nowrap; }
.value { font-weight: 700; font-variant-numeric: tabular-nums; }
.pnl { font-size: 13px; font-variant-numeric: tabular-nums; }

.detail { border-top: 1px solid var(--line); padding: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; }
.grid .v { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.detail h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 16px 0 6px; font-weight: 600; }
.fills { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.fills td { padding: 4px 0; border-top: 1px solid var(--line); }
.fills td:not(:first-child) { text-align: right; padding-left: 8px; }
.detail a { color: var(--accent); display: inline-block; margin-top: 14px; padding: 4px 0; }

.closed { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.closed-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--line); }
.closed-row:first-child { border-top: 0; }
.closed-row .mid { flex: 1; }
.empty { color: var(--muted); padding: 20px 12px; text-align: center; }

@media (min-width: 560px) {
	.stats { grid-template-columns: repeat(6, 1fr); }
	.grid { grid-template-columns: repeat(4, 1fr); }
}

body.login { display: flex; min-height: 100vh; min-height: 100dvh; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.login-card h1 { margin: 0 0 18px; font-size: 22px; }
.login-card label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.login-card input { width: 100%; padding: 12px; font-size: 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login-card button { width: 100%; margin-top: 16px; padding: 12px; font-size: 16px; font-weight: 600; border: 0; border-radius: 8px; background: var(--accent); color: #0d1117; cursor: pointer; }
.err { color: var(--down); font-size: 13px; margin: 10px 0 0; }
