/* ============================================================
   Panel de trading spot — sistema visual
   Paleta "instrumento de petróleo": fondo verde-azulado profundo,
   acento turquesa para acciones, ámbar reservado SOLO al modo real,
   verde/rojo reservados SOLO a dinero (P&L). Nada más usa esos colores.
   ============================================================ */

:root {
  --base: #0e1a1e;
  --base-2: #122329;
  --surface: #16292f;
  --surface-2: #1c333a;
  --line: #24424b;
  --line-soft: #1b343b;

  --text: #dfeaec;
  --text-dim: #8ba5ac;
  --text-faint: #5d777f;

  --accent: #3ac7b4;
  --accent-dim: #1f7f74;
  --live: #f2a93b;
  --up: #4ed07e;
  --down: #f2635f;

  --r: 10px;
  --r-sm: 6px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--base);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.98rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------- estructura */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 224px;
  flex: 0 0 224px;
  background: var(--base-2);
  border-right: 1px solid var(--line-soft);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(150deg, var(--accent), var(--accent-dim));
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: #06181a;
}
.brand-name { font-family: var(--display); font-weight: 600; font-size: 0.95rem; }
.brand-sub { font-family: var(--mono); font-size: 0.62rem; color: var(--text-faint);
  letter-spacing: 0.14em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--text-dim); font-size: 0.9rem; text-decoration: none;
}
.nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--surface-2); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.nav svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; }

.side-foot { margin-top: auto; font-size: 0.78rem; color: var(--text-faint); }
.side-foot a { color: var(--text-dim); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Barra de modo: el elemento de seguridad del panel.
   Se pone ámbar y anuncia el estado cuando hay dinero real en juego. */
.modebar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 24px;
  background: var(--base-2);
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono); font-size: 0.74rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-faint);
}
.modebar.real { background: #2a1f0c; border-bottom-color: #6b4d15; color: var(--live); }
.modebar .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.modebar.real .dot { background: var(--live); animation: pulso 2s infinite; }
.modebar .live-on { background: var(--up); }
.modebar .sep { margin-left: auto; display: flex; gap: 16px; align-items: center; }

@keyframes pulso { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .modebar.real .dot { animation: none; } }

.content { padding: 24px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-dim); font-size: 0.9rem; }
.page-head .right { margin-left: auto; display: flex; gap: 8px; }

/* ---------------------------------------------------- tarjetas */
.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.grid { display: grid; gap: 16px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------------------------------------------------- métricas */
.stat { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--r); padding: 14px 16px; }
.stat .k { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--text-faint); }
.stat .v { font-family: var(--mono); font-size: 1.45rem; font-weight: 600;
  font-variant-numeric: tabular-nums; margin-top: 3px; }
.stat .s { font-size: 0.78rem; color: var(--text-dim); }

.pos { color: var(--up); }
.neg { color: var(--down); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------- bots */
.bot-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }

/* El "riel de estado": franja vertical que codifica el estado real del bot. */
.bot {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 16px 16px 14px 20px;
  overflow: hidden;
}
.bot::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--line);
}
.bot.run::before { background: var(--accent); }
.bot.run.live::before { background: var(--live); }
.bot.err::before { background: var(--down); }

.bot-top { display: flex; align-items: baseline; gap: 8px; }
.bot-name { font-family: var(--display); font-weight: 600; font-size: 1rem; }
.bot-pair { font-family: var(--mono); font-size: 0.78rem; color: var(--text-dim); }
.bot-meta { font-size: 0.8rem; color: var(--text-dim); margin: 6px 0 12px; }
.bot-figs { display: flex; gap: 18px; margin-bottom: 12px; }
.bot-figs div { min-width: 0; }
.bot-figs .k { font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint); }
.bot-figs .v { font-family: var(--mono); font-size: 1rem; font-variant-numeric: tabular-nums; }
.bot-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------------------------------------------------- etiquetas */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.09em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 4px;
  border: 1px solid var(--line); color: var(--text-dim);
}
.tag.paper { border-color: var(--accent-dim); color: var(--accent); }
.tag.live { border-color: var(--live); color: var(--live); background: rgba(242, 169, 59, 0.1); }
.tag.run { border-color: var(--up); color: var(--up); }
.tag.err { border-color: var(--down); color: var(--down); }

/* ---------------------------------------------------- formularios */
label { display: block; font-size: 0.78rem; color: var(--text-dim); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; padding: 8px 10px;
  background: var(--base); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  font-family: var(--mono); font-size: 0.85rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.field { margin-bottom: 12px; }
.row { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
.row-3 { display: grid; gap: 10px; grid-template-columns: repeat(3, 1fr); }
.hint { font-size: 0.75rem; color: var(--text-faint); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text);
  font-family: var(--sans); font-size: 0.85rem; font-weight: 500;
  cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--line-soft); border-color: var(--line); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06181a; font-weight: 600; }
.btn-primary:hover { background: #4ad8c4; border-color: #4ad8c4; }
.btn-live { background: var(--live); border-color: var(--live); color: #241703; font-weight: 600; }
.btn-live:hover { background: #ffbc55; }
.btn-danger { border-color: #6b2b2b; color: var(--down); background: transparent; }
.btn-danger:hover { background: rgba(242, 99, 95, 0.12); }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ---------------------------------------------------- tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th {
  text-align: left; padding: 8px 10px;
  font-family: var(--mono); font-size: 0.64rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
td.n { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }
th.n { text-align: right; }

/* ---------------------------------------------------- gráficos */
.chart { width: 100%; height: 380px; }
.chart-sm { width: 100%; height: 200px; }
.chart-legend { display: flex; gap: 14px; font-family: var(--mono); font-size: 0.7rem;
  color: var(--text-dim); margin-bottom: 8px; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

/* ---------------------------------------------------- avisos */
.note {
  border-left: 3px solid var(--accent); background: var(--surface-2);
  padding: 11px 14px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 0.85rem; color: var(--text-dim);
}
.note.warn { border-left-color: var(--live); }
.note.danger { border-left-color: var(--down); }
.note strong { color: var(--text); }

.empty { text-align: center; padding: 34px 18px; color: var(--text-faint); }
.empty h3 { color: var(--text-dim); margin-bottom: 6px; }

#toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface-2); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  padding: 10px 14px; border-radius: var(--r-sm); box-shadow: var(--shadow);
  font-size: 0.85rem; max-width: 340px;
}
.toast.bad { border-left-color: var(--down); }

dialog {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 20px; width: min(560px, 92vw); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 12, 14, 0.72); }

/* ---------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: min(380px, 100%); background: var(--surface);
  border: 1px solid var(--line-soft); border-radius: 14px; padding: 30px;
}
.login-card h1 { font-size: 1.3rem; margin-bottom: 3px; }
.login-card .sub { color: var(--text-dim); font-size: 0.85rem; margin-bottom: 22px; }
.login-err {
  border-left: 3px solid var(--down); background: rgba(242, 99, 95, 0.1);
  padding: 9px 12px; border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: 0.85rem; margin-bottom: 16px; color: #ffb9b7;
}

/* ---------------------------------------------------- responsive */
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .side { width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; align-items: center; gap: 14px; padding: 10px 14px; overflow-x: auto; }
  .side-foot, .brand-sub { display: none; }
  .nav { flex-direction: row; gap: 4px; }
  .nav a span { display: none; }
  .nav a { padding: 9px; }
  .split, .g-2, .g-3, .g-4 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .modebar { padding: 8px 16px; font-size: 0.66rem; gap: 8px; }
  .modebar .sep { gap: 10px; }
}
