:root {
  color-scheme: dark;
  --bg: #090c11;
  --panel: #11161d;
  --panel-2: #161d25;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f7fa;
  --muted: #8792a2;
  --green: #46e0a0;
  --green-dark: #142c25;
  --amber: #f4bd50;
  --red: #ff5e6a;
  --red-dark: #32171c;
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 70% -20%, #17302a 0, transparent 38%), var(--bg); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; }
.noise { position: fixed; inset: 0; pointer-events: none; opacity: .025; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.shell { width: min(100%, 560px); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) 18px max(34px, env(safe-area-inset-bottom)); }
.topbar, .brand, .hero-head, .section-title, .risk-label { display: flex; align-items: center; justify-content: space-between; }
.topbar { margin: 4px 2px 20px; }
.brand { justify-content: flex-start; gap: 12px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg, #1d5b48, #10251f); box-shadow: inset 0 0 0 1px rgba(70,224,160,.2); }
.brand-mark svg { width: 28px; fill: #204c3d; stroke: var(--green); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand-mark .pulse { fill: none; stroke: #fff; }
h1, h2, p { margin: 0; }
h1 { font-size: 17px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.02em; }
.brand p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.online { background: var(--green); box-shadow: 0 0 10px rgba(70,224,160,.65); }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px; background: var(--panel); display: grid; place-items: center; }
.icon-button svg { width: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
.live-banner { margin-bottom: 10px; padding: 10px 14px; border: 1px solid rgba(255,94,106,.25); border-radius: 13px; background: rgba(70,20,26,.55); color: #ffb3b9; font-size: 12px; text-align: center; }
.live-banner span { margin-right: 8px; padding: 3px 7px; border-radius: 6px; background: var(--red); color: #190509; font-size: 10px; font-weight: 900; letter-spacing: .1em; }
.hero-card, .section-block { background: linear-gradient(155deg, rgba(24,31,40,.96), rgba(13,18,24,.98)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 16px 50px rgba(0,0,0,.24); }
.hero-card { padding: 22px; }
.eyebrow { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.balance { margin-top: 6px; font-size: clamp(32px, 10vw, 44px); font-weight: 750; letter-spacing: -.05em; font-variant-numeric: tabular-nums; }
.balance small { margin-left: 7px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.status-badge { padding: 8px 10px; border-radius: 10px; font-size: 11px; font-weight: 800; }
.status-badge.running { background: var(--green-dark); color: var(--green); box-shadow: inset 0 0 0 1px rgba(70,224,160,.16); }
.status-badge.stopped { background: #252b33; color: #aab2bd; }
.metrics { display: grid; grid-template-columns: 1fr 1fr 1.15fr; gap: 8px; margin: 20px 0; }
.metrics > div { min-width: 0; padding: 12px 10px; border-radius: 13px; background: rgba(255,255,255,.035); }
.metrics span { display: block; overflow: hidden; color: var(--muted); font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
.metrics strong { display: block; margin-top: 6px; overflow: hidden; font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; text-overflow: ellipsis; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.risk-label { margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.risk-label strong { color: var(--text); }
.track { height: 6px; overflow: hidden; border-radius: 999px; background: #252c35; }
.fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), var(--amber), var(--red)); transition: width .4s ease; }
.controls { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; margin: 14px 0 20px; }
.controls button, dialog button { min-height: 48px; border: 0; border-radius: 15px; font-weight: 800; cursor: pointer; }
.controls svg { width: 17px; margin-right: 6px; fill: currentColor; stroke: currentColor; vertical-align: -3px; }
.primary-action { background: var(--green); color: #06140e; box-shadow: 0 8px 24px rgba(70,224,160,.18); }
.secondary-action { border: 1px solid var(--line) !important; background: var(--panel-2); }
.danger-action { grid-column: 1 / -1; min-height: 42px !important; background: transparent; color: #e7858d; border: 1px solid rgba(255,94,106,.16) !important; font-size: 12px; }
button:disabled { opacity: .4; cursor: not-allowed; }
.section-block { margin-top: 12px; padding: 18px; }
.section-title { align-items: flex-start; }
.section-title h2 { margin-top: 4px; }
.confidence, .count-pill { padding: 6px 9px; border-radius: 9px; background: rgba(255,255,255,.05); color: var(--muted); font-size: 11px; font-weight: 800; }
.muted { margin-top: 12px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.decision-details { display: flex; gap: 8px; margin-top: 14px; }
.decision-details span { padding: 7px 9px; border-radius: 9px; background: rgba(255,255,255,.04); color: var(--muted); font-size: 11px; }
.list { margin-top: 12px; }
.empty-state { padding: 22px 6px; color: var(--muted); font-size: 13px; text-align: center; }
.position, .trade-row { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.position:last-child, .trade-row:last-child { border-bottom: 0; }
.position strong, .trade-row strong { font-size: 14px; }
.position span, .trade-row span { color: var(--muted); font-size: 11px; }
.position .price-line { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 22px; padding: 4px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.tab { padding: 9px 5px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 750; }
.tab.active { background: var(--panel-2); color: var(--text); box-shadow: 0 3px 12px rgba(0,0,0,.2); }
.tab-panel { display: none; margin: 10px 2px 0; }
.tab-panel.active { display: block; }
.timeline { padding: 0; text-align: left; }
.event { position: relative; margin-left: 7px; padding: 12px 8px 12px 20px; border-left: 1px solid var(--line); }
.event::before { content: ""; position: absolute; top: 17px; left: -4px; width: 7px; height: 7px; border-radius: 50%; background: #55606e; }
.event.WARNING::before { background: var(--amber); }
.event.ERROR::before, .event.CRITICAL::before { background: var(--red); }
.event strong { display: block; font-size: 12px; line-height: 1.4; }
.event span { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.rules-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; padding: 5px 0; }
.rule { padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.025); }
.rule span { display: block; color: var(--muted); font-size: 10px; }
.rule strong { display: block; margin-top: 5px; font-size: 13px; }
.config-errors { margin-top: 12px; padding: 13px; border-radius: 13px; background: var(--red-dark); color: #ffb7bd; font-size: 12px; line-height: 1.55; }
footer { padding: 28px 4px 6px; text-align: center; }
footer p { margin-top: 8px; color: #56606e; font-size: 10px; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
dialog { width: min(calc(100% - 30px), 430px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: #121820; color: var(--text); box-shadow: 0 30px 100px rgba(0,0,0,.75); }
dialog::backdrop { background: rgba(0,0,0,.75); backdrop-filter: blur(6px); }
dialog form { padding: 24px; }
.dialog-icon { width: 44px; height: 44px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 13px; background: var(--green-dark); color: var(--green); }
.dialog-icon svg { width: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
dialog h2 { font-size: 21px; }
dialog p { margin: 8px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.5; }
dialog label { display: block; margin-bottom: 7px; color: #abb4c0; font-size: 11px; font-weight: 700; }
dialog input[type="password"] { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: #090d12; color: var(--text); }
dialog input[type="password"]:focus { border-color: rgba(70,224,160,.55); box-shadow: 0 0 0 3px rgba(70,224,160,.08); }
.remember-row { margin: 13px 0 18px; color: var(--muted); font-weight: 500; }
dialog .primary-action { width: 100%; }
.toast { position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); left: 18px; z-index: 20; max-width: 520px; margin: auto; padding: 13px 15px; border: 1px solid var(--line); border-radius: 13px; background: #202833; box-shadow: 0 15px 50px rgba(0,0,0,.45); font-size: 12px; transform: translateY(100px); opacity: 0; transition: .25s ease; pointer-events: none; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { border-color: rgba(255,94,106,.25); background: var(--red-dark); color: #ffbec3; }
code { color: var(--green); }

@media (max-width: 360px) {
  .shell { padding-right: 13px; padding-left: 13px; }
  .hero-card { padding: 18px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metrics > div:last-child { grid-column: 1 / -1; }
}

@media (display-mode: standalone) {
  #installButton { display: none !important; }
}
