:root {
  color-scheme: dark;
  --bg: #090d17;
  --surface: #121928;
  --surface-2: #182235;
  --line: rgba(148, 163, 184, 0.18);
  --text: #f7fbff;
  --muted: #aab7cd;
  --soft: #7f8da7;
  --green: #22e6a4;
  --cyan: #42d6ff;
  --blue: #3e8fff;
  --yellow: #ffd166;
  --red: #ff5f7d;
  --shadow: 0 22px 55px rgba(0, 0, 0, 0.32);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% -10%, rgba(66, 214, 255, 0.13), transparent 30%),
    radial-gradient(circle at 110% 20%, rgba(34, 230, 164, 0.1), transparent 28%),
    var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.topbar,
.hero-panel,
.panel,
.tabs {
  border: 1px solid var(--line);
  background: rgba(18, 25, 40, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 18px 18px 8px 8px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: white;
  font-weight: 900;
}

.topbar h1,
.hero-panel h2,
.panel h3 {
  margin: 0;
  line-height: 1.1;
}

.topbar h1 {
  font-size: 18px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
}

.icon-button {
  width: 40px;
  height: 40px;
  margin-left: auto;
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.hero-panel {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding: 16px;
  border-radius: 8px;
}

.hero-panel h2 {
  font-size: 22px;
}

.hero-panel p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.state-pill {
  align-self: flex-start;
  min-width: 84px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255, 95, 125, 0.14);
  color: var(--red);
  text-align: center;
  font-weight: 800;
  font-size: 12px;
}

.state-pill.online {
  background: rgba(34, 230, 164, 0.14);
  color: var(--green);
}

.hero-status {
  display: grid;
  gap: 8px;
  min-width: 92px;
}

.mode-pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(66, 214, 255, 0.12);
  color: var(--cyan);
  text-align: center;
  font-weight: 900;
  font-size: 12px;
}

.tabs {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 10px 0;
  padding: 7px;
  border-radius: 12px;
}

.tab,
.action {
  min-height: 42px;
  border-radius: 10px;
  background: #202b40;
  color: #dbe7ff;
  font-weight: 800;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

.tab.active,
.action.primary {
  background: linear-gradient(135deg, #23c5ad, #2f8fff);
  color: white;
}

.action.danger {
  background: rgba(255, 95, 125, 0.2);
  color: #ffd0d8;
}

.action.full {
  width: 100%;
  margin-top: 12px;
}

.tab:active,
.action:active,
.icon-button:active {
  transform: scale(0.98);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.metric,
.mini-stat {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 13px;
}

.metric span,
.mini-stat span {
  display: block;
  color: var(--soft);
  font-size: 11px;
  text-transform: uppercase;
}

.metric strong,
.mini-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 21px;
}

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

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

.warning {
  color: var(--yellow);
}

.panel {
  margin-top: 10px;
  padding: 14px;
  border-radius: 14px;
}

.panel.compact {
  padding-bottom: 16px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.chart-panel canvas {
  width: 100%;
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0e1522;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.command-panel {
  overflow: hidden;
}

.exposure-bar {
  display: flex;
  overflow: hidden;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0e1522;
}

.exposure-bar span:first-child {
  display: block;
  min-width: 4px;
  background: linear-gradient(90deg, var(--green), var(--cyan));
}

.exposure-bar span:last-child {
  display: block;
  min-width: 4px;
  background: linear-gradient(90deg, #6b8cff, var(--red));
}

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

.cockpit-grid div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #101827;
}

.cockpit-grid span {
  display: block;
  color: var(--soft);
  font-size: 11px;
  text-transform: uppercase;
}

.cockpit-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.recommendation-list,
.performance-list {
  display: grid;
  gap: 8px;
}

.recommendation {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.recommendation strong {
  display: block;
  margin-bottom: 4px;
}

.recommendation span {
  color: #d7e2f6;
  font-size: 13px;
  line-height: 1.45;
}

.recommendation.good {
  border-color: rgba(34, 230, 164, 0.32);
}

.recommendation.warning {
  border-color: rgba(255, 209, 102, 0.34);
}

.recommendation.danger {
  border-color: rgba(255, 95, 125, 0.38);
}

.soft-text {
  margin: 0;
  color: #d7e2f6;
  font-size: 14px;
  line-height: 1.55;
}

.trade-list,
.rule-list,
.report-grid,
.pair-cloud {
  display: grid;
  gap: 8px;
}

.trade-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
}

.coin-badge {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 12px;
  background: #263653;
  color: #f7fbff;
  font-weight: 900;
}

.trade-row h4,
.coin-profile h4 {
  margin: 0;
  font-size: 15px;
}

.trade-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.trade-profit {
  font-weight: 900;
}

.coin-profile {
  display: grid;
  gap: 10px;
}

.profile-grid,
.report-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-line,
.rule-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.profile-line:last-child,
.rule-line:last-child {
  border-bottom: 0;
}

.profile-line span,
.rule-line span {
  color: var(--muted);
}

.profile-line strong,
.rule-line strong {
  text-align: right;
}

.rule-line {
  align-items: center;
}

.pair-cloud {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pair-chip {
  overflow: hidden;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: #e7f0ff;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 14px;
  z-index: 10;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 23, 36, 0.96);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 390px) {
  .app-shell {
    padding-inline: 10px;
  }

  .topbar h1 {
    font-size: 16px;
  }

  .tab,
  .action {
    font-size: 12px;
  }

  .metric strong,
  .mini-stat strong {
    font-size: 18px;
  }
}
