@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;600;700&display=swap");

:root {
  --bg: #040507;
  --bg-soft: #0a0d12;
  --card: rgba(14, 18, 24, 0.62);
  --card-solid: #11161d;
  --accent: #2ad58d;
  --accent-soft: rgba(42, 213, 141, 0.25);
  --text: #edf2f7;
  --muted: #7c8898;
  --red: #ff5f6d;
  --stroke: rgba(255, 255, 255, 0.05);
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 10px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(140% 115% at 50% 40%, #0d0d0d 0%, #080808 38%, #020202 74%, #000000 100%),
    radial-gradient(90% 80% at 50% 18%, rgba(37, 57, 79, 0.2) 0%, rgba(13, 13, 13, 0) 60%);
}

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: 14px 14px 96px;
}

.app-header {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(42, 213, 141, 0.25), rgba(42, 213, 141, 0.08));
  border: 1px solid var(--stroke);
  box-shadow: 0 0 0 1px rgba(42, 213, 141, 0.08) inset, 0 0 16px rgba(42, 213, 141, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.header-title {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.header-sub {
  font-size: 11px;
  color: var(--accent);
  opacity: 0.85;
}

.header-actions {
  display: flex;
  gap: 7px;
}

.icon-btn {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  color: #c9d1dc;
  border-radius: 11px;
  padding: 7px 9px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ===== TABS ===== */
.tab {
  display: none;
  opacity: 0;
  transform: translateY(8px);
}

.tab.active {
  display: block;
}

.tab-content {
  padding: 20px;
  color: #ffffff;
  min-height: 80vh;
  width: 100%;
  box-sizing: border-box;
  z-index: 10;
  position: relative;
}

.fade-in {
  animation: fadeIn 0.28s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== TEXT ===== */
.title {
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 16px;
}

.label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.4);
}

.portfolio-label {
  font-size: 10.5px;
  opacity: 0.4;
  letter-spacing: 0.04em;
}

.green {
  color: var(--accent);
  text-shadow: 0px 0px 12px rgba(16, 185, 129, 0.35);
}

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

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

select {
  background: rgba(20, 25, 32, 0.78);
  color: var(--text);
  border: 1px solid var(--stroke);
  padding: 8px 12px;
  border-radius: 11px;
}

/* ===== CARDS ===== */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 19px;
  margin-bottom: 16px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.balance-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045) 0%, rgba(255, 255, 255, 0.008) 46%, rgba(255, 255, 255, 0.02) 100%),
    var(--card);
}

.card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.09);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.34), 0 0 20px rgba(42, 213, 141, 0.08);
}

.status-pills {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.pill {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
}

/* ===== GRID ===== */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== CHART ===== */
.chart {
  height: 210px;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 250px;
  min-height: 200px;
  overflow: hidden;
  border-radius: 12px;
  margin-bottom: 10px;
}

canvas {
  width: 100%;
  height: 100%;
}

/* ===== TRADES ===== */
.trade {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
}

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

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 13px 0 10px;
}

.quick-item {
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  color: #d7e0ec;
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.quick-item::after {
  content: "›";
  margin-left: 8px;
  color: rgba(255, 255, 255, 0.55);
}

.quick-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ===== LOGS ===== */
.log {
  font-size: 12px;
  margin-bottom: 6px;
}

.log.success {
  color: var(--accent);
}

.log.error {
  color: var(--red);
}

.terminal-logs {
  background: #0a0a0a;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 15px;
  height: 60vh;
  overflow-y: auto;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  color: #a3a3a3;
}

.log-entry {
  margin-bottom: 10px;
  border-bottom: 1px dashed #222;
  padding-bottom: 10px;
}

.log-time {
  color: #666;
  margin-right: 10px;
}

.log-msg.short {
  color: #ef4444;
}

.log-msg.long {
  color: #10b981;
}

.text-success {
  color: #10b981;
}

.text-danger {
  color: #ef4444;
}

/* ===== INPUT ===== */
input {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: rgba(8, 11, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  color: #f4f7fb;
}

/* ===== BUTTON ===== */
.btn {
  margin-top: 12px;
  width: 100%;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #031109;
  font-weight: 700;
  cursor: pointer;
  transition: 0.2s;
  box-shadow: 0 0 16px rgba(42, 213, 141, 0.3);
}

.btn:hover {
  opacity: 0.9;
}

.noir-btn,
.noir-btn-small {
  border: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(35, 41, 48, 0.9), rgba(24, 29, 35, 0.9));
  color: #e9eff6;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.noir-btn {
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.noir-btn-small {
  padding: 8px 11px;
  font-size: 11px;
  font-weight: 700;
}

.noir-btn--paused {
  background: linear-gradient(180deg, #37df94, #22ba79);
  color: #021107;
  box-shadow: 0 0 14px rgba(42, 213, 141, 0.33);
}

.btn-success {
  background: linear-gradient(180deg, #33e89b, #26c682);
  color: #031109;
  box-shadow: 0 0 14px rgba(42, 213, 141, 0.4);
}

.loading {
  opacity: 0.7;
  pointer-events: none;
}

.control-panel h3 {
  margin-bottom: 8px;
}

.noir-input-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.input-label {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-group input {
  width: 76px;
  margin-top: 0;
  text-align: right;
}

.input-suffix {
  color: rgba(255, 255, 255, 0.4);
}

.pnl-value--profit,
.pct-change--up,
.profit {
  color: var(--accent);
  text-shadow: 0px 0px 12px rgba(16, 185, 129, 0.35);
}

.pnl-value--loss,
.pct-change--down,
.loss {
  color: var(--red);
}

.balance-value,
#balance,
#dailyPnl,
#stat-winrate,
#stat-trades,
#stat-net-pnl,
.stat-value,
.coin-name,
.coin-pair,
.pct-change,
.pnl-value,
.positions-table td,
.positions-table th {
  font-family: "JetBrains Mono", monospace;
}

#balance {
  font-size: 44px;
  font-weight: 700;
  letter-spacing: -1px;
  color: #ffffff;
  line-height: 1.02;
  margin-top: 2px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

#stat-winrate,
#stat-trades,
#stat-net-pnl,
.pct-change,
.pnl-value,
.positions-table td,
.coin-name {
  letter-spacing: -1px;
}

#balance .balance-amount {
  font-size: 1em;
  font-weight: 800;
}

#balance .balance-currency {
  font-size: 0.7em;
  font-weight: 700;
  opacity: 0.78;
  letter-spacing: -0.3px;
  margin-bottom: 2px;
}

#dailyPnl {
  font-size: 16px;
  font-weight: 700;
  margin-top: 2px;
  line-height: 1.1;
}

.stat-value,
#stat-winrate,
#stat-trades,
#stat-net-pnl {
  color: #ffffff;
  font-weight: 700;
}

.stat-label,
.portfolio-label,
.card-label,
.section-title,
.coin-pair,
.positions-table th {
  color: rgba(255, 255, 255, 0.4);
}

/* ===== NAVBAR ===== */
.navbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  background: rgba(6, 7, 9, 0.82);
  border-top: 1px solid var(--stroke);
  display: flex;
  justify-content: space-around;
  padding: 7px 8px calc(7px + env(safe-area-inset-bottom, 0px));
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.navbar button {
  background: none;
  border: none;
  color: #8592a4;
  font-size: 11px;
  cursor: pointer;
}

.navbar button:hover {
  color: var(--accent);
}

.nav-item--active {
  color: var(--accent) !important;
  text-shadow: 0 0 8px rgba(42, 213, 141, 0.28);
}

#app-heartbeat {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(62px + env(safe-area-inset-bottom, 0px));
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(8, 10, 13, 0.75);
  color: #8d99aa;
  font-size: 10px;
  font-family: "JetBrains Mono", monospace;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

#watchlist {
  display: grid;
  gap: 8px;
}

.coin-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.coin-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d5dee8;
  font-weight: 700;
}

.positions-table {
  width: 100%;
  border-collapse: collapse;
}

.positions-table th,
.positions-table td {
  padding: 10px 7px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
}

.active-position-card {
  margin-top: -2px;
}

.active-position-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.active-position-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.active-coin-logo {
  width: 38px;
  height: 38px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
}

.active-title {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.active-sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  margin-top: 2px;
}

.active-position-pnl {
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -1px;
  white-space: nowrap;
}

.active-stats-grid {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 0.5px solid rgba(255, 255, 255, 0.05);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.active-stat-label {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}

.active-stat-val {
  margin-top: 3px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: -0.6px;
  color: #e9eef5;
}

.positions-table th {
  color: #8e9bad;
  font-size: 11px;
}

#log-container {
  white-space: pre-wrap;
  max-height: 45vh;
  overflow-y: auto;
  background: rgba(7, 9, 12, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 10px;
  font-family: "JetBrains Mono", monospace;
  color: #9aa6b7;
}

/* --- Market sentiment (Dashboard) --- */
.sentiment-wrap {
  margin-top: 12px;
}

.sentiment-caption {
  margin-bottom: 4px;
}

.sentiment-track {
  display: flex;
  height: 5px;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
  border: 0.5px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.08);
}

.sentiment-seg {
  height: 100%;
  flex: 0 0 auto;
  min-width: 0;
  transition: width 0.35s ease;
}

.sentiment-seg--long {
  background: linear-gradient(90deg, #059669, #10b981);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.35);
}

.sentiment-seg--short {
  background: linear-gradient(90deg, #f87171, #ef4444);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

.sentiment-seg--neutral {
  background: rgba(255, 255, 255, 0.12);
}

.sentiment-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.sentiment-legend-long {
  color: #10b981;
}

.sentiment-legend-short {
  color: #f87171;
}

/* --- Markets: price + signal --- */
.coin-price-mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.4px;
  color: #f0f4f8;
}

.coin-price-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.signal-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 999px;
  border: 0.5px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.signal-badge--long {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.signal-badge--short {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(248, 113, 113, 0.1);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.15);
}

.signal-badge--wait {
  color: rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.04);
}

/* --- Markets tab (grid cards) --- */
.markets-card-shell {
  padding: 12px 14px 14px;
}

.markets-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.market-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
}

.market-row:hover {
  border-color: rgba(255, 255, 255, 0.1);
}

.market-row-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.market-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #e4ebf4;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset;
}

.market-ticker-block {
  min-width: 0;
}

.market-ticker {
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.4px;
  color: #f5f8fc;
}

.market-sub {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.38);
  margin-top: 2px;
}

.market-row-mid {
  text-align: right;
}

.market-price-mono {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: #f0f4f8;
}

.market-row-right {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
}

.market-badge {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
}

.market-badge--long {
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.18);
}

.market-badge--short {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.1);
  box-shadow: 0 0 10px rgba(248, 113, 113, 0.12);
}

.market-badge--wait {
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
}

.market-trend {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.market-trend--up {
  background: #10b981;
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.55);
}

.market-trend--down {
  background: #f87171;
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.45);
}

.market-trend--flat {
  background: rgba(255, 255, 255, 0.25);
}

.market-toggle {
  flex-shrink: 0;
}

.market-toggle input.toggle {
  margin: 0;
}
