:root {
  --bg-base: #070913;
  --bg-panel: rgba(15, 20, 36, 0.78);
  --bg-elevated: rgba(26, 33, 56, 0.85);
  --border: rgba(148, 163, 184, 0.14);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --cyan: #22d3ee;
  --green: #10b981;
  --green-bg: rgba(16, 185, 129, 0.14);
  --red: #f43f5e;
  --red-bg: rgba(244, 63, 94, 0.14);
  --amber: #f59e0b;
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(99, 102, 241, 0.14) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(34, 211, 238, 0.10) 0%, transparent 45%);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, .brand-name { font-family: 'Space Grotesk', sans-serif; }

.mono { font-family: 'JetBrains Mono', monospace; }
.hidden { display: none !important; }

/* LOGIN */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #172033 0%, var(--bg-base) 60%);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.brand-logo.small { width: 32px; height: 32px; border-radius: 8px; }
.login-brand h1 { font-size: 1.25rem; font-weight: 700; }
.login-brand p { font-size: 0.82rem; color: var(--text-muted); }

.login-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 16px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus { border-color: var(--accent); }

.login-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-hint code {
  background: var(--bg-elevated);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-main);
}

/* BOTONES */
button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--accent);
  color: white;
  padding: 11px 18px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-full { width: 100%; }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-secondary:hover { background: #252d3f; }

.btn-withdraw {
  background: var(--green);
  color: #06281e;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-withdraw.locked {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-icon {
  background: transparent;
  color: var(--text-muted);
  padding: 8px;
  border-radius: 8px;
}
.btn-icon:hover { color: var(--text-main); background: var(--bg-elevated); }

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-name { font-weight: 700; font-size: 1.05rem; }
.badge-sim {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  letter-spacing: 0.5px;
}

.topbar-stats { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-pill {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
}
.stat-label { font-size: 0.7rem; color: var(--text-muted); }
.stat-value { font-size: 0.92rem; font-weight: 600; }
.stat-value.pos { color: var(--green); }
.stat-value.neg { color: var(--red); }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* MAIN GRID */
.main-grid {
  display: grid;
  grid-template-columns: 290px 1fr 320px;
  gap: 16px;
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
  min-height: calc(100vh - 70px);
}

.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.panel-header h2 { font-size: 1rem; font-weight: 600; }
.live-dot { font-size: 0.72rem; color: var(--green); font-weight: 600; }

/* MERCADOS */
.crypto-list { display: flex; flex-direction: column; gap: 8px; }
.crypto-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg-base);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}
.crypto-item:hover { border-color: var(--border); background: var(--bg-elevated); }
.crypto-item.active { border-color: var(--accent); background: rgba(59, 130, 246, 0.08); }

.crypto-left { display: flex; align-items: center; gap: 10px; }
.crypto-icon-sm { width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; }
.crypto-name { font-size: 0.9rem; font-weight: 600; }
.crypto-sym { font-size: 0.75rem; color: var(--text-muted); }

.crypto-right { text-align: right; }
.crypto-price { font-size: 0.88rem; font-weight: 600; }
.crypto-chg { font-size: 0.75rem; font-weight: 500; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.sidebar-chart-box {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 4px;
}
.sidebar-canvas-wrap {
  height: 150px;
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
#sidebar-pnl-chart { width: 100%; height: 100%; display: block; }
.sidebar-tx-history {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  max-height: 170px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.35;
}
.sidebar-tx-item {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.sidebar-tx-item:last-child { border-bottom: none; }
.sidebar-tx-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.72rem;
}
.tx-badge {
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.65rem;
}
.tx-badge.buy { background: var(--green-bg); color: var(--green); }
.tx-badge.sell { background: var(--red-bg); color: var(--red); }
.tx-badge.hist { background: rgba(59, 130, 246, 0.15); color: var(--accent); }

/* GRÁFICA */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.selected-crypto-info { display: flex; align-items: center; gap: 12px; }
.crypto-icon-lg svg { width: 38px; height: 38px; }
.crypto-title-row { display: flex; align-items: center; gap: 8px; }
.symbol-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 6px;
}
.price-row { display: flex; align-items: baseline; gap: 10px; margin-top: 4px; }
.current-price { font-size: 1.5rem; font-weight: 700; }
.price-change { font-size: 0.85rem; font-weight: 600; padding: 2px 8px; border-radius: 6px; }
.price-change.pos { background: var(--green-bg); color: var(--green); }
.price-change.neg { background: var(--red-bg); color: var(--red); }

.chart-metrics { display: flex; gap: 20px; }
.metric { display: flex; flex-direction: column; }
.metric-label { font-size: 0.72rem; color: var(--text-muted); }
.metric-val { font-size: 0.9rem; font-weight: 600; margin-top: 2px; }

.chart-container {
  flex: 1;
  min-height: 340px;
  position: relative;
  background: var(--bg-base);
  border-radius: 10px;
  padding: 12px;
  border: 1px solid var(--border);
}
#price-chart { width: 100%; height: 100%; display: block; }

/* TERMINAL TRADE */
.trade-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.trade-tab {
  padding: 10px;
  border-radius: 8px;
  background: var(--bg-base);
  color: var(--text-muted);
  font-weight: 600;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-secondary.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: var(--accent);
  color: var(--accent);
}
.trade-tab.active.buy { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.trade-tab.active.sell { background: var(--red-bg); color: var(--red); border-color: var(--red); }

.available-box {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.input-with-suffix { position: relative; display: flex; align-items: center; }
.input-with-suffix input { padding-right: 52px; }
.input-with-suffix span {
  position: absolute;
  right: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
}

.quick-pcts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 16px; }
.quick-pcts button {
  background: var(--bg-elevated);
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
}
.quick-pcts button:hover { color: var(--text-main); background: #283144; }

.btn-trade {
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 6px;
}
.btn-trade.buy { background: var(--green); color: #052e16; }
.btn-trade.sell { background: var(--red); color: white; }

.trade-feedback {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  text-align: center;
}
.trade-feedback.ok { background: var(--green-bg); color: var(--green); }
.trade-feedback.err { background: var(--red-bg); color: var(--red); }

.holdings-breakdown {
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
.holdings-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.holding-bar-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.holding-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
}
.holding-bar-track {
  height: 7px;
  background: var(--bg-base);
  border-radius: 99px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.holding-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease;
}
.btn-sell-all {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(244, 63, 94, 0.3);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.68rem;
  font-weight: 700;
}
.btn-sell-all:hover { background: var(--red); color: white; }

/* MODALES */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.7); backdrop-filter: blur(4px); }
.modal-content {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  z-index: 1;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}
.modal-lg { max-width: 760px; }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-close { background: transparent; color: var(--text-muted); font-size: 1.5rem; line-height: 1; }
.modal-close:hover { color: var(--text-main); }
.modal-body { padding: 20px; }
.modal-desc { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; }

.withdraw-body { text-align: center; }
.alert-box {
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  padding: 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-bottom: 18px;
  text-align: left;
}
.qr-wrapper { display: flex; justify-content: center; margin-bottom: 12px; }
.wallet-address {
  background: var(--bg-base);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.82rem;
  margin-bottom: 10px;
  word-break: break-all;
}
.sim-note { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 16px; }

/* TABLA HISTORIAL */
.table-wrap { overflow-x: auto; max-height: 400px; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.history-table th, .history-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.history-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; }
.empty-row { text-align: center !important; color: var(--text-muted); padding: 28px !important; }

/* RULETA DE PREMIOS */
.roulette-body { text-align: center; }
.roulette-container {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 0 auto 16px;
}
.roulette-pointer {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.5rem;
  color: #fbbf24;
  z-index: 2;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}
#roulette-canvas {
  border-radius: 50%;
  border: 4px solid var(--border);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
  transition: transform 3.8s cubic-bezier(0.17, 0.67, 0.12, 0.99);
}
.roulette-result {
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid rgba(16, 185, 129, 0.35);
  padding: 10px 14px;
  border-radius: 8px;
  font-weight: 600;
  margin-bottom: 14px;
  font-size: 0.9rem;
}

/* VENTANAS FLOTANTES DE GUÍA */
.onboarding-tips {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 14, 0.72);
  backdrop-filter: blur(3px);
  pointer-events: auto;
  z-index: 850;
}
.tip-card {
  position: absolute;
  width: 260px;
  background: rgba(19, 23, 34, 0.98);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.65);
  pointer-events: auto;
}
.tip-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}
.tip-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.tip-close {
  background: transparent;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
}
.tip-close:hover { color: var(--text-main); }
.btn-hide-tips {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #070913;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 7px 16px;
  border-radius: 8px;
  pointer-events: auto;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
}
.btn-hide-tips:hover { background: #fbbf24; }

/* CHATBOT WEBGPU */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 900;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: white;
  padding: 12px 18px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(59, 130, 246, 0.4);
}
.chat-fab:hover { transform: translateY(-2px); }

.chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: calc(100vh - 48px);
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}
.chat-title { display: flex; align-items: center; gap: 10px; }
.chat-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.chat-title small { display: block; font-size: 0.72rem; color: var(--text-muted); }

.chat-progress-wrap { padding: 8px 14px; background: var(--bg-base); border-bottom: 1px solid var(--border); }
.chat-progress-text { font-size: 0.74rem; color: var(--text-muted); margin-bottom: 4px; }
.chat-progress-bar { height: 5px; background: var(--bg-elevated); border-radius: 99px; overflow: hidden; }
.chat-progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.2s; }

.chat-messages {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.45;
}
.msg.bot { background: var(--bg-elevated); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--accent); color: white; align-self: flex-end; border-bottom-right-radius: 4px; }

.chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-base);
}
.chat-input-area input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--text-main);
  outline: none;
}

@media (max-width: 1100px) {
  .main-grid { grid-template-columns: 1fr; }
}
