:root {
  color-scheme: dark;
  --bg: #070a11;
  --bg-soft: #0c111c;
  --card: #111722;
  --card-2: #151c29;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #8f98a8;
  --blue: #3da2ff;
  --green: #20d48b;
  --red: #ff4d67;
  --amber: #ffb84c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 0%, rgba(61, 162, 255, 0.18), transparent 34%),
    radial-gradient(circle at 90% 20%, rgba(32, 212, 139, 0.10), transparent 28%),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button,
select,
input {
  max-width: 100%;
}

button {
  min-width: 0;
}

.app {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  overflow-x: hidden;
  padding: max(14px, env(safe-area-inset-top)) 14px calc(112px + env(safe-area-inset-bottom));
}

.app-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  min-width: 0;
}

.app-header > div {
  min-width: 0;
}

.overline {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  margin-top: 5px;
  font-size: clamp(30px, 7.2vw, 40px);
}

h2 {
  font-size: 28px;
}

.screen {
  display: none;
  animation: screen-in 180ms ease-out;
}

.screen.active {
  display: grid;
  gap: 18px;
}

@keyframes screen-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel {
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.hero {
  padding: 20px;
}

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 22px;
}

.status-row div,
.kpi-grid div {
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.status-row span,
.kpi-grid span,
.money-main span,
.muted,
.field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.status-row strong,
.kpi-grid strong {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money-main {
  margin-bottom: 16px;
}

.money-main strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(38px, 12vw, 56px);
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  font-weight: 800;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 20px rgba(32, 212, 139, 0.7);
}

.status-dot.warning {
  background: var(--amber);
  box-shadow: 0 0 20px rgba(255, 184, 76, 0.7);
}

.status-dot.danger {
  background: var(--red);
  box-shadow: 0 0 20px rgba(255, 77, 103, 0.7);
}

.action-stack {
  display: grid;
  gap: 14px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.compact-row {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 10px;
}

.btn {
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  color: var(--text);
  font-weight: 850;
  letter-spacing: 0;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, #1588ff, #35c0ff);
  color: #04111f;
}

.btn-secondary {
  background: linear-gradient(135deg, #1b2535, #263347);
}

.btn-danger {
  background: linear-gradient(135deg, #ff365c, #b91534);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--text);
}

.full {
  width: 100%;
}

.section-title {
  margin-bottom: 12px;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.launch-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.launch-summary div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
}

.launch-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.launch-summary strong {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input {
  width: 100%;
  min-height: 54px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  background: #080c14;
  color: var(--text);
  font-size: 16px;
}

.input:focus {
  border-color: rgba(61, 162, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(61, 162, 255, 0.12);
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.chip,
.seg {
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip.active,
.seg.active {
  background: #f4f7fb;
  color: #080b12;
}

.pair-list {
  display: grid;
  gap: 10px;
  max-height: 230px;
  margin-top: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.pair-item,
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  text-align: left;
}

.pair-item > div,
.list-item > div {
  min-width: 0;
}

.pair-item > span,
.list-item > span {
  flex: 0 0 auto;
  max-width: 48%;
  overflow: hidden;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pair-item.active {
  border-color: rgba(61, 162, 255, 0.75);
  background: rgba(61, 162, 255, 0.12);
}

.pair-item strong,
.list-item strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pair-item span,
.list-item span,
.hint,
.compact-text {
  color: var(--muted);
  line-height: 1.45;
}

.pair-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.pair-head > div:first-child {
  min-width: 0;
}

.badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(61, 162, 255, 0.14);
  color: #8ed0ff;
  font-size: 12px;
  font-weight: 850;
}

.badge.bad {
  background: rgba(255, 77, 103, 0.14);
  color: #ff9aaa;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.info {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}

.info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 8px;
}

.segmented.small .seg {
  min-height: 38px;
  font-size: 13px;
}

.hint {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 184, 76, 0.12);
  color: #ffdca5;
}

.deal-explain {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 14px;
  border: 1px solid rgba(61, 162, 255, 0.25);
  border-radius: 18px;
  background: rgba(61, 162, 255, 0.10);
  line-height: 1.35;
}

.deal-explain strong {
  color: var(--text);
}

.deal-explain span {
  color: var(--muted);
}

.deal-explain .warn-text {
  color: #ffdca5;
  font-weight: 800;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  margin-top: 10px;
  padding: 0 2px;
  color: var(--text);
  font-weight: 800;
}

.toggle-line input {
  width: 22px;
  height: 22px;
}

.mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.list {
  display: grid;
  gap: 10px;
}

.profit {
  color: var(--green);
}

.loss {
  color: var(--red);
}

.chart {
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #080c14;
  overflow: hidden;
}

.chart.large {
  height: 260px;
}

.chart-toolbar {
  display: grid;
  gap: 14px;
}

.timeframe-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.timeframe-row .chip {
  min-height: 38px;
  padding: 0 4px;
  font-size: 12px;
}

.market-line {
  margin: 12px 0;
  color: var(--muted);
  font-weight: 800;
  line-height: 1.35;
}

.chart svg {
  width: 100%;
  height: 100%;
  display: block;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 82px 1fr 72px;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.bottom-nav {
  position: fixed;
  right: max(12px, calc((100vw - 560px) / 2 + 12px));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, calc((100vw - 560px) / 2 + 12px));
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(7, 10, 17, 0.92);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
}

.nav {
  min-height: 48px;
  padding: 0 3px;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.nav.active {
  background: #f4f7fb;
  color: #080b12;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(12px);
}

.modal-card {
  width: min(100%, 480px);
  max-height: 82vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.modal-title {
  margin-bottom: 12px;
  font-size: 22px;
  font-weight: 900;
}

.preview {
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border-radius: 16px;
  background: #080c14;
  color: var(--muted);
  white-space: pre-wrap;
}

.toast {
  position: sticky;
  top: 8px;
  z-index: 10;
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(61, 162, 255, 0.16);
  border: 1px solid rgba(61, 162, 255, 0.35);
  color: var(--text);
  font-weight: 800;
}

.hidden {
  display: none !important;
}

@media (max-width: 390px) {
  .app {
    padding-right: 12px;
    padding-left: 12px;
  }

  .panel {
    padding: 14px;
    border-radius: 22px;
  }

  .button-row:not(.compact-row) {
    grid-template-columns: 1fr;
  }

  .segmented {
    gap: 10px;
  }

  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeframe-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .status-row,
  .kpi-grid,
  .launch-summary {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    left: 8px;
    right: 8px;
  }

  .nav {
    font-size: 11px;
  }
}

@media (max-width: 340px) {
  h1 {
    font-size: 28px;
  }

  .info-grid,
  .status-row,
  .kpi-grid,
  .chip-grid,
  .mini-grid,
  .launch-summary {
    grid-template-columns: 1fr;
  }

  .timeframe-row {
    grid-template-columns: repeat(2, 1fr);
  }
}
