:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0d1a2c;
  --surface-2: #122238;
  --line: rgba(154, 178, 213, 0.12);
  --text: #f4f7fb;
  --muted: #8391a8;
  --blue: #2f91ff;
  --cyan: #42d9d1;
  --green: #2ed49b;
  --red: #ff6577;
  --yellow: #f8c65a;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 88% -8%, rgba(47, 145, 255, 0.16), transparent 27rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom));
}

.topbar, .asset-head, .section-title, .proposal-top, .risk-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 4px;
  color: #65809f;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 { margin: 0; font-size: 25px; letter-spacing: -0.03em; }

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(46, 212, 155, 0.28);
  border-radius: 999px;
  padding: 8px 11px;
  background: rgba(46, 212, 155, 0.1);
  color: #76e7bd;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.mode-badge > span:first-child:not(:last-child) {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 10px var(--green);
}

.portfolio-card, .chart-card, .signal-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background: linear-gradient(150deg, rgba(18, 34, 56, 0.96), rgba(10, 24, 41, 0.94));
  box-shadow: 0 16px 35px rgba(0, 0, 0, 0.14);
}

.portfolio-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px 24px;
  margin-top: 22px;
  padding: 18px;
}

.muted { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.balance { margin: 0; font-size: 27px; font-weight: 750; letter-spacing: -0.04em; }
.balance small { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.pnl-block { text-align: right; }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.pnl-block .positive { margin: 0; font-weight: 750; }

.risk-meter { grid-column: 1 / -1; }
.risk-copy { margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.risk-copy strong { color: #aab7c9; }
.risk-track { height: 5px; overflow: hidden; border-radius: 99px; background: #1c2b40; }
.risk-track span { display: block; width: 4%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--blue)); }

.coins {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin: 16px 0;
}

.coin, .timeframe, .nav-item {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.coin {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(16, 31, 51, 0.72);
  font-size: 11px;
  font-weight: 800;
}

.coin.active {
  border-color: rgba(47, 145, 255, 0.52);
  background: linear-gradient(135deg, rgba(47, 145, 255, 0.22), rgba(66, 217, 209, 0.1));
  color: #eaf4ff;
  box-shadow: inset 0 0 0 1px rgba(47, 145, 255, 0.08);
}

.chart-card { padding: 17px 14px 13px; }
.asset-title { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.coin-icon { display: grid; width: 26px; height: 26px; place-items: center; border-radius: 9px; background: #f2a900; color: #121a25; font-weight: 900; }
.price-row { display: flex; align-items: baseline; gap: 9px; margin-top: 8px; }
#price { font-size: 24px; font-weight: 760; letter-spacing: -0.035em; }
.price-row small { font-size: 11px; font-weight: 750; }
.live-pill { display: flex; align-items: center; gap: 6px; color: #7f91a9; font-size: 9px; font-weight: 850; letter-spacing: 0.08em; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 9px var(--green); }
.live-pill.offline { color: #a98288; }
.live-pill.offline i { background: var(--red); box-shadow: 0 0 9px rgba(255,101,119,.55); }

.timeframes { display: flex; gap: 4px; margin-top: 16px; }
.timeframe { min-width: 42px; padding: 6px 10px; border-radius: 9px; font-size: 11px; font-weight: 700; }
.timeframe.active { background: rgba(47, 145, 255, 0.14); color: #70b5ff; }

.chart-wrap { position: relative; height: 210px; margin: 4px -4px 0; }
#chart { display: block; width: 100%; height: 100%; }
.chart-legend { position: absolute; top: 5px; left: 8px; display: flex; gap: 10px; font-size: 9px; font-weight: 750; }
.ema20 { color: #57c7ff; }
.ema50 { color: #bb7dff; }
.updated { margin: 1px 5px 0; color: #62738b; font-size: 9px; }

.signal-card { margin-top: 14px; padding: 17px; }
.section-title > div { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.signal-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--yellow); box-shadow: 0 0 12px rgba(248, 198, 90, 0.5); }
.neutral-chip { border-radius: 7px; padding: 5px 7px; background: rgba(248, 198, 90, 0.1); color: #e6be68; font-size: 8px; font-weight: 850; letter-spacing: 0.08em; }
.signal-copy { margin: 14px 0 16px; color: #a4b1c3; font-size: 12px; line-height: 1.5; }
.signal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.signal-stats div { padding: 10px; border-radius: 12px; background: rgba(6, 17, 31, 0.52); }
.signal-stats span, .proposal-grid span { display: block; color: #73839a; font-size: 9px; }
.signal-stats strong { display: block; margin-top: 5px; font-size: 11px; }

.primary-action, .confirm-action, .secondary-action {
  border: 0;
  border-radius: 15px;
  cursor: pointer;
  font-weight: 800;
}

.primary-action {
  width: 100%;
  min-height: 52px;
  margin-top: 14px;
  background: linear-gradient(135deg, #2d83f5, #25a9ed);
  color: white;
  box-shadow: 0 14px 30px rgba(47, 145, 255, 0.22);
}
.primary-action:active, .confirm-action:active { transform: translateY(1px); }
.paper-note { margin: 10px 0 0; color: #5e6f87; text-align: center; font-size: 9px; }

.bottom-nav {
  position: fixed;
  z-index: 20;
  bottom: 0;
  left: 50%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  width: min(100%, 480px);
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
  background: rgba(7, 17, 31, 0.93);
  backdrop-filter: blur(18px);
}
.nav-item { display: flex; min-height: 48px; flex-direction: column; align-items: center; justify-content: center; gap: 4px; border-radius: 12px; font-size: 9px; }
.nav-item span { font-size: 19px; font-weight: 500; }
.nav-item b { font: inherit; }
.nav-item.active { color: #55a8ff; background: rgba(47, 145, 255, 0.08); }
.nav-item.paused { color: var(--yellow); }

.sheet-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 14px;
  background: rgba(2, 8, 16, 0.7);
  backdrop-filter: blur(6px);
}
.sheet-backdrop[hidden] { display: none; }
.proposal-sheet {
  width: min(100%, 460px);
  border: 1px solid rgba(126, 162, 205, 0.18);
  border-radius: 26px;
  padding: 10px 18px max(18px, env(safe-area-inset-bottom));
  background: #0f1d30;
  box-shadow: 0 -18px 60px rgba(0,0,0,.35);
  animation: sheet-in .22s ease-out;
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
.sheet-handle { width: 38px; height: 4px; margin: 0 auto 17px; border-radius: 99px; background: #30425a; }
.proposal-top h2 { margin: 0; font-size: 19px; }
.mode-badge.compact { padding: 6px 8px; font-size: 9px; }
.proposal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.proposal-grid div { padding: 12px; border-radius: 13px; background: #091526; }
.proposal-grid strong { display: block; margin-top: 6px; font-size: 12px; }
.proposal-reason { margin: 14px 2px; color: #8d9bb0; font-size: 11px; line-height: 1.45; }
.sheet-actions { display: grid; grid-template-columns: .82fr 1.4fr; gap: 9px; }
.secondary-action, .confirm-action { min-height: 48px; }
.secondary-action { background: #1a2a3f; color: #aab8c9; }
.confirm-action { background: linear-gradient(135deg, #1f8fef, #2ba9e9); color: white; }

.toast {
  position: fixed;
  z-index: 80;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100% - 30px);
  transform: translate(-50%, -16px);
  border: 1px solid rgba(46, 212, 155, 0.25);
  border-radius: 13px;
  padding: 11px 14px;
  background: #10263a;
  color: #dffaf0;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 700px) {
  body { padding: 24px 0; }
  .app-shell { min-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 30px; box-shadow: 0 28px 80px rgba(0,0,0,.3); }
  .bottom-nav { bottom: 24px; border: 1px solid var(--line); border-radius: 0 0 30px 30px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
