:root {
  --bg: #101312; --side: #121614; --panel: #171b1a; --panel-2: #1b211d; --sunk: #121614;
  --line: #2b322d; --line-2: #36402f; --text: #e9ede6; --muted: #8b958d; --dim: #6f7a71;
  --green: #c0eb91; --green-ink: #29391e; --green-soft: #243020; --green-line: #384a2e;
  --red: #ed8a7c; --red-soft: #30241f; --red-line: #49342b;
  --amber: #e9c27a; --amber-soft: #2e2a1d; --amber-line: #4a4027;
  --blue: #9cc3e6; --blue-soft: #1d2833; --blue-line: #2e4152;
  --r: 10px; --side-w: 236px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; min-height: 100vh; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.hidden { display: none !important; }
h1, h2, h3 { margin: 0; }
b { font-weight: 600; }
.muted { color: var(--muted); } .subtle { color: var(--dim); font-size: 12px; margin: 0; } .small { font-size: 12px; }
.error { color: var(--red); min-height: 1em; margin: 0; font-size: 13px; }
.up, .long { color: var(--green); } .down, .short { color: var(--red); }
code { font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--blue); word-break: break-all; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#i-home rect { fill: none; }

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Manrope', sans-serif; font-size: 22px; font-weight: 800; letter-spacing: -.8px; }
.brand b { color: var(--green); font-weight: 800; }
.brand-mark { width: 30px; height: 30px; color: var(--green); stroke-width: 2.4; }

/* Sidebar */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--side); border-right: 1px solid var(--line); padding: 26px 16px 18px; display: flex; flex-direction: column; gap: 30px; z-index: 20; }
.sidebar .brand { padding: 0 10px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-btn { position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 7px; color: #929c94; font-size: 13px; font-weight: 500; text-align: left; transition: background .15s, color .15s; }
.nav-btn:hover { background: #1c231e; color: var(--text); }
.nav-btn.active { background: var(--green-soft); color: var(--green); }
.side-nav .nav-btn.active::before { content: ''; position: absolute; left: -16px; width: 3px; height: 22px; background: var(--green); border-radius: 0 3px 3px 0; }
.nav-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-left: auto; }
.side-foot { margin-top: auto; padding: 0 10px; }
.side-foot .subtle { font-size: 11px; line-height: 1.6; }

/* Shell */
.shell { margin-left: var(--side-w); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 10; height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 32px; background: rgba(18,22,20,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.top-title h1 { font-family: 'Manrope', sans-serif; font-size: 21px; font-weight: 750; letter-spacing: -.6px; }
.eyebrow { font-size: 10px; letter-spacing: 1.6px; color: #9eb78d; font-weight: 600; text-transform: uppercase; }
.top-right { display: flex; align-items: center; gap: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--panel); }
main { max-width: 1180px; margin: 0 auto; padding: 26px 32px 70px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.view > *, .grid-2 > * { min-width: 0; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .4px; border: 1px solid var(--line-2); color: var(--muted); background: var(--panel); white-space: nowrap; }
.pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.live, .verdict.live { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }
.pill.dry, .verdict.dry { color: var(--blue); border-color: var(--blue-line); background: var(--blue-soft); }
.pill.paused, .verdict.paused { color: var(--amber); border-color: var(--amber-line); background: var(--amber-soft); }
.pill.live::before { animation: pulse 1.8s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(192,235,145,.55); } 50% { box-shadow: 0 0 0 5px rgba(192,235,145,0); } }

/* Panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 22px; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.section-title > div:first-child, .advanced summary { display: flex; align-items: center; gap: 10px; }
.section-title h2, .advanced h2 { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.num { font-size: 10px; color: #7d9070; border: 1px solid #34402d; border-radius: 4px; padding: 3px 5px; line-height: 1; font-variant-numeric: tabular-nums; }
.link { color: var(--green); font-size: 12px; font-weight: 600; }
.body { color: #b9c2ba; margin: 0 0 14px; font-size: 13px; line-height: 1.65; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }

/* Hero */
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 24px; align-items: stretch; }
.verdict { display: inline-flex; align-items: center; gap: 12px; margin: 10px 0 8px; padding: 0; border: 0; background: none !important; font-family: 'Manrope', sans-serif; font-size: 40px; font-weight: 800; letter-spacing: -1.4px; line-height: 1.1; }
.verdict i { width: 12px; height: 12px; border-radius: 50%; background: currentColor; }
.verdict.live i { animation: pulse 1.8s infinite; }
.verdict-sum { margin: 0 0 6px; font-size: 14px; color: #cfd7cf; line-height: 1.6; }
.verdict-cfg { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; }
.hero-side { display: flex; flex-direction: column; gap: 14px; justify-content: space-between; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--sunk); border: 1px solid var(--line); }
.check i { margin-top: 5px; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--green); }
.check.bad i { background: var(--amber); }
.check b { display: block; font-size: 12px; font-weight: 600; }
.check small { display: block; font-size: 11px; color: var(--muted); }
.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-actions .btn { flex: 1 1 auto; }

/* Stats strip */
.strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: #151a17; }
.stat { padding: 16px 18px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.stat:last-child { border-right: 0; }
.stat span { font-size: 11px; color: var(--muted); font-weight: 500; }
.stat b { font-family: 'Manrope', sans-serif; font-size: 21px; font-weight: 750; letter-spacing: -.5px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #151916; }
.tabs button { padding: 6px 11px; border-radius: 5px; color: #929c8f; font-size: 12px; font-weight: 500; }
.tabs button.active { background: #303e28; color: #d6edbf; }

/* Positions */
.pos-list { display: flex; flex-direction: column; gap: 10px; }
.pos { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--panel-2); }
.pos-top { display: flex; align-items: center; gap: 10px; }
.coin { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.coin-ic { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #222a24; color: var(--green); font-size: 10px; font-weight: 700; flex: none; }
.coin b { display: block; font-size: 14px; }
.coin small { display: block; font-size: 11px; color: var(--muted); }
.side { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 4px; border: 1px solid; }
.side.long { color: #b7dc92; background: var(--green-soft); border-color: var(--green-line); }
.side.short { color: #e3a597; background: var(--red-soft); border-color: var(--red-line); }
.pnl { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 80px; text-align: right; }
.pos dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; margin: 14px 0 0; }
.pos dt, .cmp dt { font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; }
.pos dd, .cmp dd { margin: 2px 0 0; font-size: 13px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.empty { text-align: center; padding: 26px 10px; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: 8px; }
#pos-note { margin-top: 12px; }

/* Feed / logs */
.feed { display: flex; flex-direction: column; }
#logs { max-height: none; }
.log { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.log:last-child { border-bottom: 0; }
.log-ic { flex: none; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #222a24; color: var(--muted); }
.log.trade .log-ic { background: var(--blue-soft); color: var(--blue); }
.log.warn .log-ic { background: var(--amber-soft); color: var(--amber); }
.log.error .log-ic { background: var(--red-soft); color: var(--red); }
.log-body { min-width: 0; flex: 1; }
.log-body p { margin: 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.log-body p.open { -webkit-line-clamp: unset; }
.log.error .log-body p { color: #f0b3a8; }
.log-body time { display: block; font-size: 11px; color: var(--dim); margin-top: 3px; }

/* Orders table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }

/* Trader page */
.current { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 8px; background: var(--green-soft); border: 1px solid var(--green-line); margin-bottom: 18px; flex-wrap: wrap; }
.current .coin-ic { background: #2f3d27; }
.current-info { flex: 1; min-width: 0; }
.current-info b { display: block; font-size: 14px; }
.current-info code { color: #b7dc92; font-size: 11px; }
.current-stats { display: flex; gap: 18px; }
.current-stats div { display: flex; flex-direction: column; }
.current-stats span { font-size: 10px; color: #9eb78d; text-transform: uppercase; letter-spacing: .6px; }
.current-stats b { font-variant-numeric: tabular-nums; }
.note { margin-top: 12px; padding: 11px 13px; border-radius: 8px; font-size: 13px; border: 1px solid var(--line); background: var(--sunk); }
.note.ok { border-color: var(--green-line); background: var(--green-soft); color: #d6edbf; }
.note.bad { border-color: var(--red-line); background: var(--red-soft); color: #f0b3a8; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.keybox { display: flex; flex-direction: column; gap: 4px; background: var(--sunk); border: 1px dashed var(--line-2); border-radius: 8px; padding: 10px 12px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cmp { padding: 16px; border-radius: 8px; background: var(--panel-2); border: 1px solid var(--line); }
.cmp > span { font-size: 11px; color: var(--muted); }
.cmp > b { display: block; font-family: 'Manrope', sans-serif; font-size: 22px; font-weight: 750; letter-spacing: -.5px; margin: 2px 0 10px; font-variant-numeric: tabular-nums; }
.cmp dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.ok-text { color: var(--green); font-size: 12px; font-weight: 600; } .bad-text { color: var(--amber); font-size: 12px; font-weight: 600; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 13px; border-radius: 7px; padding: 10px 16px; border: 1px solid var(--line-2); background: #1d231f; color: var(--text); transition: filter .15s, transform .05s, background .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.15); } .btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: #bfe890; border-color: #c8f19b; color: var(--green-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red-line); }
.btn.warn { background: var(--amber-soft); color: var(--amber); border-color: var(--amber-line); }
.btn.lg { padding: 12px 20px; font-size: 14px; } .btn.block { width: 100%; }

/* Forms */
.settings { display: flex; flex-direction: column; gap: 18px; }
.fields { display: grid; gap: 14px; }
.fields.two { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
.fields.three { grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.field { display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.field em { font-style: normal; color: var(--dim); }
.field.narrow { max-width: 260px; margin-top: 12px; }
input, select { font: inherit; font-size: 15px; color: var(--text); background: var(--sunk); border: 1px solid var(--line-2); border-radius: 7px; padding: 11px 12px; width: 100%; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus { border-color: #8fb46a; box-shadow: 0 0 0 3px rgba(192,235,145,.12); }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.hint { color: var(--dim); font-size: 12px; margin: 12px 0 0; line-height: 1.6; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #151916; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; width: 1px; }
.seg span { display: block; padding: 8px 16px; border-radius: 6px; color: #929c8f; font-size: 13px; font-weight: 500; text-align: center; transition: background .15s, color .15s; }
.seg input:checked + span { background: #303e28; color: #d6edbf; }
.seg input:focus-visible + span { outline: 2px solid var(--green); }
.leg { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-bottom: 10px; }
.leg-title { font-weight: 600; font-size: 13px; margin-bottom: 10px; }
.switch { position: relative; display: flex; align-items: center; gap: 12px; margin-top: 16px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { flex: none; width: 40px; height: 23px; border-radius: 999px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #e9ede6; transition: transform .15s; }
.switch input:checked + .track { background: #8fbf63; }
.switch input:checked + .track::after { transform: translateX(17px); }
.switch b { display: block; font-size: 13px; }
.switch small { display: block; font-size: 12px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.chip { font-size: 11px; color: var(--muted); padding: 4px 8px; border: 1px solid var(--line); border-radius: 5px; background: var(--sunk); }
.chip b { color: var(--text); font-weight: 600; margin-right: 4px; }
.advanced summary { cursor: pointer; list-style: none; }
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 18px; }
.advanced[open] summary::after { content: '–'; }
.advanced[open] summary { margin-bottom: 18px; }
.savebar { position: sticky; bottom: 14px; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 10px 10px 16px; background: rgba(23,27,26,.95); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid var(--line-2); border-radius: var(--r); }
.savebar.dirty { border-color: var(--amber-line); }
.savebar.dirty #save-msg { color: var(--amber); }

.banner { padding: 13px 16px; border-radius: var(--r); border: 1px solid var(--amber-line); color: var(--amber); background: var(--amber-soft); font-size: 13px; margin-bottom: 18px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 50; max-width: min(92vw, 460px); padding: 12px 16px; border-radius: 9px; font-size: 13px; background: #222a24; border: 1px solid var(--line-2); box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.toast.ok { border-color: var(--green-line); color: #d6edbf; } .toast.bad { border-color: var(--red-line); color: #f0b3a8; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 30px 26px; }
.login-card h1 { font-family: 'Manrope', sans-serif; font-size: 24px; letter-spacing: -.8px; margin-top: 14px; }
.login-card p { margin: 0; }

.bottom-nav { display: none; }

@media (max-width: 1060px) {
  .hero { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .shell { margin-left: 0; }
  .topbar { height: 62px; padding: 0 16px; }
  .top-title h1 { font-size: 18px; }
  main { padding: 16px 12px calc(96px + env(safe-area-inset-bottom)); }
  .view, .settings { gap: 12px; }
  .panel { padding: 16px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(18,22,20,.97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav .nav-btn { flex-direction: column; justify-content: center; gap: 3px; font-size: 11px; padding: 7px 2px; }
  .bottom-nav .nav-btn svg { width: 20px; height: 20px; }
  .bottom-nav .nav-dot { position: absolute; top: 6px; right: calc(50% - 16px); margin: 0; }
  .savebar { bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .verdict { font-size: 34px; }
  .strip { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(2) { border-right: 0; }
  .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .stat b { font-size: 19px; }
}
@media (max-width: 520px) {
  .pill { padding: 5px 10px; font-size: 11px; }
  .checks { grid-template-columns: 1fr 1fr; }
  .hero-actions .btn.lg { flex-basis: 100%; }
  .pos dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .compare { grid-template-columns: 1fr; }
  .seg { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .seg span { padding: 10px 6px; }
  .field.narrow { max-width: none; }
  .section-title .tabs { width: 100%; }
  .section-title .tabs button { flex: 1; }
  .row .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.hero-main .eyebrow { display: block; }

.btn.sm { padding: 8px 12px; font-size: 12px; }
.pos-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.pos-actions .chip { margin-right: auto; color: var(--amber); border-color: var(--amber-line); }
.modal { width: min(94vw, 440px); padding: 0; border: 1px solid var(--line-2); border-radius: 12px; background: var(--panel); color: var(--text); box-shadow: 0 24px 60px rgba(0,0,0,.55); }
.modal::backdrop { background: rgba(4,6,5,.7); }
.modal form { display: flex; flex-direction: column; gap: 10px; padding: 18px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-info { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); margin-bottom: 4px; }
.modal-info span { display: block; font-size: 10px; color: var(--dim); text-transform: uppercase; letter-spacing: .6px; }
.modal-info b { font-size: 13px; font-variant-numeric: tabular-nums; }
.quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--sunk); color: var(--muted); }
.chip-btn:hover { color: var(--text); border-color: var(--line-2); }
.est { font-size: 12px; min-height: 1em; color: var(--dim); } .est.up { color: var(--green); } .est.down { color: var(--red); }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-actions #prot-auto { margin-right: auto; }
@media (max-width: 860px) { .pos-actions .btn { flex: 1; } .modal-actions .btn { flex: 1; } }
.pct-seg { display: grid; grid-template-columns: repeat(4, 1fr); }
.close-sum { margin: 4px 0 0; font-size: 13px; line-height: 1.5; }
.close-sum .up, .modal-info .up { color: var(--green); } .close-sum .down, .modal-info .down { color: var(--red); }
.btn.danger-fill { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }

/* partial TP + PnL history */
.pos dl .wide { grid-column: 1 / -1; }
.ptp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.pnl-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.pnl-big { font-size: 28px; font-weight: 800; }
.pnl-chart { width: 100%; height: 140px; display: block; margin-bottom: 14px; }
.pnl-chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; }
.pnl-chart.up .line { stroke: var(--green); } .pnl-chart.down .line { stroke: var(--red); }
.pnl-chart .area { stroke: none; opacity: .12; } .pnl-chart.up .area { fill: var(--green); } .pnl-chart.down .area { fill: var(--red); }
.pnl-chart .zero { stroke: var(--line-2); stroke-dasharray: 4 4; vector-effect: non-scaling-stroke; }
.pnl-strip { margin-bottom: 12px; }
.pnl-coins { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.strip.pnl-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 700px) { .strip.pnl-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pnl-big { font-size: 24px; } }

/* Leaderboard */
.lb-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.lb-controls .field { flex: 1 1 260px; margin: 0; }
.lb-toggle { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.lb-meta { margin-bottom: 12px; }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); }
.lb-row.mine { border-color: var(--green-line); }
.lb-sum { display: grid; grid-template-columns: 44px minmax(150px, 1.6fr) repeat(5, minmax(0, 1fr)); gap: 10px; align-items: center; width: 100%; padding: 10px 12px; text-align: left; font-variant-numeric: tabular-nums; }
.lb-sum > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-sum small { display: block; color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; }
.lb-rank { color: var(--muted); font-weight: 700; }
.lb-wallet b { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.lb-head { color: var(--dim); font-size: 10px; text-transform: uppercase; letter-spacing: .4px; padding: 0 12px 2px; }
.lg { font-size: 10px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); margin-left: 6px; color: var(--muted); }
.lg-Challenger { color: #f0b6ff; border-color: #5b3d66; } .lg-Diamond { color: var(--blue); border-color: var(--blue-line); }
.lg-Platinum { color: #b9e3d6; border-color: #3a5a50; } .lg-Gold { color: var(--amber); border-color: var(--amber-line); }
.lg-Silver { color: #cfd5d0; }
.lb-detail { border-top: 1px solid var(--line); padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.lb-detail .strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.lb-detail .stat { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.lb-detail .stat b { font-size: 15px; }
.lb-detail code { font-size: 11px; }
.lb-bars { width: 100%; height: 70px; display: block; }
.lb-bars .up { fill: var(--green); } .lb-bars .down { fill: var(--red); } .lb-bars line { stroke: var(--line-2); }
.lb-detail .row { flex-wrap: wrap; }
@media (max-width: 860px) {
  .lb-sum { grid-template-columns: 34px minmax(0, 1fr) repeat(2, minmax(0, auto)); }
  .lb-sum .lb-hide { display: none; }
  .lb-head { display: none; }
  .lb-detail .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav { grid-template-columns: repeat(6, 1fr); }
}

.move-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 14px 0 18px; }
#move-form .btn { align-self: end; }
.move-log { margin: 14px 0 0; padding-left: 20px; font-size: 13px; line-height: 1.7; overflow-wrap: anywhere; }
.move-log li.ok { color: #d6edbf; } .move-log li.bad { color: var(--red); } .move-log li.info { color: var(--muted); }
.note a { color: inherit; font-weight: 600; word-break: break-all; }

.wallet-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; scrollbar-width: none; }
.wallet-bar:empty { display: none; }
.wallet-bar::-webkit-scrollbar { display: none; }
.wchip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font-size: 13px; text-align: left; min-width: 112px; }
.wchip b { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.wchip small { color: var(--muted); font-size: 11px; }
.wchip.active { border-color: #c8f19b; background: #1f2a1b; }
.wchip.add { justify-content: center; align-items: center; color: var(--muted); border-style: dashed; min-width: 0; }
.wchip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.wchip .dot.on { background: #9fd86b; } .wchip .dot.dry { background: var(--amber); } .wchip .dot.err { background: var(--red); }
.extra-status { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.extra-status:empty { display: none; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.ov-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; margin-top: 12px; }
.ov-card h4 { margin: 0 0 10px; font-size: 13px; }
.eq-chart { width: 100%; height: 160px; }
.eq-chart .line { fill: none; stroke: #bfe890; stroke-width: 2; vector-effect: non-scaling-stroke; }
code { word-break: break-all; }

/* Alignment polish */
.field em { display: block; margin-top: -3px; font-size: 11px; line-height: 1.4; }
.panel > .subtle + .fields, .panel > .hint + .fields, .fields + .fields, .leg + .fields { margin-top: 14px; }
.section-title + .hint, .section-title + .subtle { margin-top: -6px; }
.section-title > .subtle { text-align: right; }
.panel > .switch + .switch { margin-top: 12px; }
#notify-form { display: flex; flex-direction: column; }
#notify-form > .switch { margin-top: 14px; }
#notify-form > .switch:first-child { margin-top: 0; }
#notify-form > .fields { margin-top: 14px; }
#notify-form > details.hint summary { cursor: pointer; }
#notify-form > .field { margin-top: 18px; }
.send-me { margin: 22px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.switch-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 12px 20px; }
.switch-grid .switch { margin: 0; }
.row-btns .btn { flex: 1 1 140px; }
.ov-card { background: var(--panel-2); }
.ov-card:first-child { margin-top: 0; }
.ov-card .fields { gap: 12px; }
.current-info b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savebar #save-msg { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.savebar .btn { flex: none; }
@media (min-width: 861px) { .row-btns .btn { flex: 0 0 auto; } }
@media (max-width: 520px) {
  .ov-card .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ov-card input, .ov-card select { font-size: 14px; }
  .section-title > .subtle { text-align: left; }
}
#tfa-panel > .fields { margin-top: 14px; }

/* Trade tab */
.tr-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 24px; padding: 16px 22px; }
.tr-sym { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.tr-sym select { width: auto; min-width: 170px; font-weight: 600; }
.tr-ivs, .tr-seg, .tr-pcts { display: flex; gap: 4px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #151916; }
.tr-ivs button, .tr-seg button, .tr-pcts button { flex: 1; padding: 7px 11px; border-radius: 6px; color: #929c8f; font-size: 13px; font-weight: 500; }
.tr-ivs button.active, .tr-seg button.active { background: var(--green-soft); color: var(--green); }
.tr-seg button.short.active { background: #3a2020; color: #f07167; }
.tr-seg.two button { padding: 10px; font-weight: 600; }
.tr-seg.sm button { padding: 7px; font-weight: 500; }
.tr-pcts { padding: 0; border: 0; background: none; gap: 8px; margin-top: -4px; }
.tr-pcts button { border: 1px solid var(--line); padding: 6px 0; }
.tr-stats { display: grid; grid-template-columns: repeat(6, auto); gap: 4px 26px; }
.tr-stats div, .tr-kv div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tr-stats small, .tr-kv small { color: var(--muted); font-size: 11px; }
.tr-stats span { font-variant-numeric: tabular-nums; font-size: 14px; white-space: nowrap; }
.tr-up { color: var(--green); } .tr-dn { color: #f07167; }
.tr-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.tr-chart-panel { padding: 10px; }
#tr-chart { width: 100%; height: 460px; }
.tr-grid.top { align-items: stretch; }
.tr-grid.top .tr-chart-panel { display: flex; }
.tr-grid.top #tr-chart { flex: 1; height: auto; min-height: 460px; }
.tr-order .fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tr-order form { display: flex; flex-direction: column; gap: 14px; }
.tr-order .fields { margin: 0; }
.tr-order .field b { color: var(--green); margin-left: 4px; }
.tr-order input[type=range] { width: 100%; accent-color: #c0eb91; padding: 0; background: none; border: 0; }
.tr-sum { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; font-size: 12px; color: var(--muted); padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--sunk); }
.tr-sum b { color: var(--text); font-weight: 500; }
.tr-go { width: 100%; padding: 13px; font-size: 15px; }
.tr-go.short { background: #f07167; border-color: #f07167; color: #2a1212; }
.tr-side-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.tr-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tr-kv.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tr-kv b, .tr-kv span { font-variant-numeric: tabular-nums; font-size: 14px; overflow: hidden; text-overflow: ellipsis; }
.tr-move { display: flex; gap: 8px; margin-top: 14px; }
.tr-move input { flex: 1 1 90px; min-width: 0; }
.tr-move .btn { flex: none; }
.tr-book { display: flex; flex-direction: column; font-size: 12px; font-variant-numeric: tabular-nums; }
.tr-book-h, .tr-book button { display: grid; grid-template-columns: 1fr 1fr; padding: 3px 8px; }
.tr-book-h { color: var(--muted); font-size: 11px; }
.tr-book-h span:last-child, .tr-book button span:last-child { text-align: right; }
.tr-book button { position: relative; text-align: left; border-radius: 4px; }
.tr-book button:hover { background: #1c231e; }
.tr-book button i { position: absolute; right: 0; top: 1px; bottom: 1px; border-radius: 3px; opacity: .16; }
.tr-book .ask span:first-child { color: #f07167; } .tr-book .ask i { background: #f07167; }
.tr-book .bid span:first-child { color: var(--green); } .tr-book .bid i { background: #c0eb91; }
.tr-book span { position: relative; }
.tr-mid { padding: 8px; margin: 4px 0; text-align: center; font-weight: 600; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.tr-mid small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.tr-card { border: 1px solid var(--line); border-radius: 8px; padding: 14px; background: var(--panel-2); }
.tr-card + .tr-card { margin-top: 12px; }
.tr-card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.tr-card-h b { margin-left: auto; font-variant-numeric: tabular-nums; }
.tr-go-sym { font-weight: 700; font-size: 15px; }
.tag.long { color: var(--green); background: var(--green-soft); } .tag.short { color: #f07167; background: #3a2020; }
.tag { padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 600; }
.tr-prot { display: flex; gap: 8px; margin-top: 12px; }
.tr-prot input { flex: 1 1 0; min-width: 0; }
.tr-prot .btn { flex: none; }
.tr-ord { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
#tr-orders .leg-title { margin-top: 18px; }
@media (max-width: 1100px) { .tr-stats { grid-template-columns: repeat(3, auto); } }
@media (max-width: 960px) { .tr-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .tr-head { padding: 14px 16px; }
  .tr-sym, .tr-sym select { width: 100%; }
  .tr-ivs { width: 100%; }
  .tr-stats { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; }
  .tr-grid.top #tr-chart, #tr-chart { min-height: 340px; height: 340px; }
  .tr-kv.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav .nav-btn { font-size: 10px; }
}
