/* =====================================================================
   Copiador — sistema visual
   Fondo slate-950; acento azul eléctrico / cian para lo interactivo;
   esmeralda y rojo SOLO para PnL y lado (Long/Short); bento + glass sutil.
   ===================================================================== */
:root {
  --bg: #020617;
  --glass: rgba(15, 23, 42, 0.62);
  --glass-2: rgba(30, 41, 59, 0.45);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --blue: #F97316;
  --blue-2: #FDBA74;
  --cyan: #FDBA74;
  --blue-soft: rgba(249, 115, 22, 0.16);
  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.14);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, 0.14);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.16);

  --font: "Inter", "Geist", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;
  --r: 12px; --r-sm: 8px; --r-xs: 6px;
  --rail: 232px; --topbar: 58px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(249, 115, 22, 0.10), transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.tabular-nums, .num, .v, td.num, .pnl { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
a { color: var(--blue-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; color: var(--text); }
h3 { font-size: 13.5px; }
p { margin: 0 0 8px; max-width: 66ch; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.hidden { display: none !important; }
.ic { display: inline-flex; vertical-align: middle; line-height: 0; }
.ic svg { width: 16px; height: 16px; }
.ic.amber { color: var(--amber); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: var(--rail) 1fr; grid-template-rows: var(--topbar) 1fr; min-height: 100vh; }
.rail {
  grid-row: 1 / span 2;
  background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; }
.brand .mark { width: 28px; height: 28px; }
.brand .lock svg { display: block; }
.brand .name { font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--r-sm); color: var(--text-2); font-weight: 500; border: 1px solid transparent; }
.nav a .ic svg { width: 18px; height: 18px; }
.nav a:hover { background: var(--glass-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--blue-soft); color: #ffedd5; border-color: rgba(249, 115, 22, 0.35); }
.nav a .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--red); }
.rail .spacer { flex: 1; }
.rail .user { padding: 10px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); }
.rail .user strong { color: var(--text); display: block; overflow: hidden; text-overflow: ellipsis; }

.topbar {
  grid-column: 2; position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; padding: 0 28px;
  background: rgba(2, 6, 23, 0.6); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 600; font-size: 14px; }
.topbar .spacer { flex: 1; }
.trust { display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--glass); font-size: 12.5px; color: var(--text-2); }
.trust strong { color: var(--text); font-weight: 500; }
.trust .led { width: 8px; height: 8px; border-radius: 50%; background: var(--emerald); position: relative; }
.trust .led::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--emerald); opacity: 0; animation: pulse 1.6s ease-out infinite; }
.trust.off .led { background: var(--red); }
.trust.off .led::after { animation: none; }
@keyframes pulse { 0% { transform: scale(0.6); opacity: 0.8; } 100% { transform: scale(1.4); opacity: 0; } }

.main { grid-column: 2; padding: 22px 28px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head p { margin: 3px 0 0; color: var(--text-2); }
.page-actions { display: flex; gap: 8px; align-items: center; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
  .rail { grid-row: 1; position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 10px; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a span.lbl { display: none; }
  .rail .spacer, .rail .user, .brand .name { display: none; }
  .topbar { grid-column: 1; padding: 0 14px; flex-wrap: wrap; height: auto; min-height: var(--topbar); }
  .main { grid-column: 1; padding: 16px 14px 50px; }
}

/* ---------- controles ---------- */
button, .btn { font: inherit; font-weight: 500; color: var(--text); background: var(--glass-2); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 8px 14px; cursor: pointer; }
button:hover, .btn:hover { border-color: rgba(255,255,255,0.28); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #0B1220; }
button.primary:hover { background: #fb8a3c; }
button.danger { background: var(--red-soft); border-color: rgba(248,113,113,0.5); color: #fecaca; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover { color: var(--text); background: var(--glass-2); }
button.sm { padding: 5px 10px; font-size: 12.5px; }

label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea { font: inherit; color: var(--text); background: rgba(2, 6, 23, 0.6); border: 1px solid var(--border-2); border-radius: var(--r-sm); padding: 8px 10px; width: 100%; }
input:focus, select:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .field { flex: 1; min-width: 140px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.check input { width: auto; }

/* toggle estilo iOS */
.toggle { position: relative; width: 46px; height: 26px; background: #334155; border-radius: 13px; border: none; padding: 0; flex-shrink: 0; transition: background 0.15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.4); transition: transform 0.15s; }
.toggle[aria-checked="true"] { background: var(--blue); }
.toggle[aria-checked="true"]::after { transform: translateX(20px); }
.toggle.lg { width: 56px; height: 32px; border-radius: 16px; }
.toggle.lg::after { width: 26px; height: 26px; }
.toggle.lg[aria-checked="true"]::after { transform: translateX(24px); }

/* selector rápido de multiplicador */
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--r-xs); overflow: hidden; }
.seg button { border: none; border-radius: 0; background: transparent; padding: 4px 9px; font-size: 12px; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--blue-soft); color: #ffedd5; }

/* ---------- superficies (glass) ---------- */
.card { background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; }
.card h2 { margin-bottom: 10px; }
.bento { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; } .span-6 { grid-column: span 6; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 1100px) { .span-3 { grid-column: span 6; } .span-4 { grid-column: span 6; } .span-8, .span-6 { grid-column: span 12; } }
@media (max-width: 640px) { .span-3, .span-4 { grid-column: span 12; } }

.span-2 { grid-column: span 2; }
@media (max-width: 1100px) { .span-2 { grid-column: span 4; } }
@media (max-width: 640px) { .span-2 { grid-column: span 6; } }
.hero-pnl { display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.hero-pnl .l { color: var(--text-2); font-size: 12.5px; }
.hero-pnl .big { font-size: clamp(44px, 5.2vw, 72px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; display: flex; align-items: center; gap: 12px; }
.hero-pnl .arrow { font-size: 0.6em; }
.hero-pnl.pos .big { color: var(--emerald); text-shadow: 0 0 28px rgba(52, 211, 153, 0.35); }
.hero-pnl.neg .big { color: var(--red); text-shadow: 0 0 28px rgba(248, 113, 113, 0.35); }
.hero-pnl.flat .big { color: var(--text); }
.hero-pnl.pos::before, .hero-pnl.neg::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 60%; height: 140%; border-radius: 50%; filter: blur(60px); opacity: 0.18; pointer-events: none; }
.hero-pnl.pos::before { background: var(--emerald); }
.hero-pnl.neg::before { background: var(--red); }
.hero-pnl .s { color: var(--text-3); font-size: 12.5px; text-transform: capitalize; }
.metric { display: flex; flex-direction: column; gap: 4px; min-height: 96px; }
.metric .l { color: var(--text-2); font-size: 12.5px; }
.metric .v { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.metric .s { color: var(--text-3); font-size: 12px; margin-top: auto; }
.pos { color: var(--emerald); }
.neg { color: var(--red); }

.notice { border: 1px solid var(--border); border-left: 3px solid var(--blue); background: var(--blue-soft); padding: 10px 14px; border-radius: var(--r-sm); margin: 12px 0; }
.notice.danger { border-left-color: var(--red); background: var(--red-soft); }
.notice.ok { border-left-color: var(--emerald); background: var(--emerald-soft); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--glass-2); color: var(--text-2); border: 1px solid var(--border); }
.badge.on { color: var(--emerald); border-color: rgba(52,211,153,0.35); background: var(--emerald-soft); }
.badge.off { color: var(--red); border-color: rgba(248,113,113,0.35); background: var(--red-soft); }
.badge.blue { color: #ffedd5; border-color: rgba(249,115,22,0.4); background: var(--blue-soft); }
.badge.amber { color: var(--amber); border-color: rgba(251,191,36,0.4); background: var(--amber-soft); }
.badge.long { color: var(--emerald); border-color: rgba(52,211,153,0.35); background: var(--emerald-soft); font-weight: 600; }
.badge.short { color: var(--red); border-color: rgba(248,113,113,0.35); background: var(--red-soft); font-weight: 600; }
.badge .led { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ---------- tablas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-3); font-weight: 500; font-size: 12px; }
td.num, th.num { text-align: right; }
tr:last-child td { border-bottom: none; }
.table-wrap { overflow-x: auto; }
.sym { font-weight: 600; letter-spacing: 0.01em; }

/* ---------- onboarding ---------- */
.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.step { background: var(--glass); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; color: inherit; }
.step:hover { text-decoration: none; border-color: var(--border-2); }
.step .n { width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-2); display: grid; place-items: center; font-size: 12px; flex-shrink: 0; }
.step.done .n { background: var(--blue); border-color: var(--blue); color: #0B1220; }
.step.current { border-color: rgba(249,115,22,0.5); box-shadow: 0 0 0 3px var(--blue-soft); }
.step.current .n { border-color: var(--blue); color: var(--blue-2); }
.step h3 { font-size: 13.5px; }
.step p { font-size: 12.5px; color: var(--text-2); margin: 2px 0 0; }
@media (max-width: 1000px) { .steps { grid-template-columns: 1fr 1fr; } }

/* ---------- auth ---------- */
/* ---------- entrada / registro ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: 36px 44px; background: linear-gradient(160deg, #0e1526 0%, #070b16 60%); border-right: 1px solid var(--border); overflow: hidden; }
.auth-brand::before { content: ""; position: absolute; inset: -30% auto auto -20%; width: 70%; height: 90%; background: radial-gradient(closest-side, rgba(249,115,22,.18), transparent); filter: blur(40px); pointer-events: none; }
.auth-brand-top { display: flex; justify-content: space-between; align-items: center; position: relative; }
.auth-brand .brand .name { font-size: 20px; }
.auth-brand-body { position: relative; max-width: 520px; margin: 40px 0; }
.auth-brand-body h2 { font-size: clamp(26px, 2.8vw, 36px); line-height: 1.12; letter-spacing: -.02em; margin-bottom: 12px; }
.auth-brand-body > p { color: var(--text-2); font-size: 16px; margin-bottom: 18px; }
.auth-brand .points { list-style: none; padding: 0; margin: 0 0 22px; display: grid; gap: 8px; }
.auth-brand .points li { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 14px; }
.auth-brand .points i { color: var(--emerald); font-style: normal; font-weight: 700; }
.auth-brand-foot { color: var(--text-3); font-size: 12px; position: relative; }
.auth-map { background: var(--glass); border: 1px solid var(--border); border-radius: 16px; padding: 14px; backdrop-filter: blur(10px); }
.auth-map .topline { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.auth-map .live { display: inline-flex; align-items: center; gap: 6px; color: var(--emerald); }
.auth-map .live i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 8px var(--emerald); }
.auth-map .pnl { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; padding: 10px 12px; border: 1px solid var(--border-2); border-radius: 10px; background: rgba(7,11,22,.7); }
.auth-map .pnl small { color: var(--text-2); font-size: 12px; }
.auth-map .pnl b { color: var(--emerald); font-size: 20px; letter-spacing: -.02em; text-shadow: 0 0 18px rgba(52,211,153,.35); }
.auth-form { display: grid; place-items: center; padding: 40px 24px; }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 26px; letter-spacing: -.02em; margin-bottom: 6px; }
.auth-box .sub { color: var(--text-2); margin-bottom: 22px; }
.auth-box button.primary { width: 100%; margin-top: 6px; padding: 12px; font-size: 15px; }
.auth-box .switch { text-align: center; margin-top: 18px; color: var(--text-2); }
.auth-box .terms { text-align: center; margin-top: 12px; color: var(--text-3); font-size: 12px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px; border-radius: 10px; border: 1px solid var(--border-2); background: #fff; color: #1f2937; font-weight: 600; font-size: 14px; }
.btn-google:hover { background: #f3f4f6; }
.or { display: flex; align-items: center; gap: 12px; margin: 16px 0; color: var(--text-3); font-size: 12px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.lang { display: inline-flex; border: 1px solid var(--border-2); border-radius: 999px; overflow: hidden; }
.lang button { border: 0; border-radius: 0; background: transparent; color: var(--text-2); padding: 5px 10px; font-size: 11px; font-weight: 700; letter-spacing: .08em; }
.lang button.on { background: rgba(255,255,255,.08); color: var(--text); }
.only-mobile { display: none; }
@media (max-width: 860px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .only-mobile { display: flex; justify-content: center; margin-bottom: 18px; }
  .auth-form { padding: 28px 18px; min-height: 100vh; }
  .auth-box h1 { text-align: center; } .auth-box .sub { text-align: center; }
}
.error { color: #fecaca; font-size: 13px; margin: 8px 0 0; }

/* ---------- mapper (grupos) ---------- */
.mapper { position: relative; min-height: 380px; }
.mapper svg { width: 100%; height: 100%; display: block; }
.mapper-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-2); text-align: center; padding: 20px; }
.node { cursor: pointer; }
.node rect { fill: rgba(15, 23, 42, 0.85); stroke: var(--border-2); stroke-width: 1; rx: 10; }
.node.primary rect { stroke: rgba(251, 191, 36, 0.6); }
.node.selected rect { stroke: var(--blue); stroke-width: 1.5; }
.node.off rect { stroke-dasharray: 4 3; }
.node text { fill: var(--text); font-family: var(--font); font-size: 13px; font-variant-numeric: tabular-nums; }
.node text.sub { fill: var(--text-2); font-size: 11.5px; }
.node text.pnl { font-weight: 600; }
.link { stroke: rgba(148, 163, 184, 0.35); stroke-width: 1.5; fill: none; }
.link.on { stroke: var(--blue); opacity: 0.85; }
.link.off { stroke-dasharray: 5 4; opacity: 0.5; }
.pulse { fill: var(--cyan); filter: drop-shadow(0 0 4px var(--cyan)); }
@keyframes travel { from { offset-distance: 0%; } to { offset-distance: 100%; } }

.follower { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.follower:first-child { border-top: none; }
.follower .nm { font-weight: 500; }
.follower .meta { color: var(--text-2); font-size: 12px; }

.group-list { display: flex; flex-direction: column; gap: 6px; }
.group-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--glass); cursor: pointer; }
.group-item:hover { border-color: var(--border-2); }
.group-item.active { border-color: rgba(249,115,22,0.6); background: var(--blue-soft); }
.group-item .name { flex: 1; font-weight: 500; }
.group-item .led { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.group-item .led.on { background: var(--emerald); }
.cockpit { display: grid; grid-template-columns: 240px 1fr; gap: 14px; }
@media (max-width: 1000px) { .cockpit { grid-template-columns: 1fr; } }
.drawer { margin-top: 14px; }
.drawer h2 { display: flex; align-items: center; gap: 10px; }
.sec-rule { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.sec-rule .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sec-rule .head strong { flex: 1; }
.pick-list { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; }
.pick { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.pick input { width: auto; }
.pick .meta { margin-left: auto; color: var(--text-2); font-size: 12px; }

/* ---------- actividad ---------- */
.feed { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow: auto; }
.ev { display: grid; grid-template-columns: 56px 1fr; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: rgba(2,6,23,0.5); border-left: 2px solid var(--border-2); font-size: 12.5px; }
.ev .t { color: var(--text-3); }
.ev.warn { border-left-color: var(--amber); }
.ev.bad { border-left-color: var(--red); }
.ev.good { border-left-color: var(--emerald); }
.emergency { width: 100%; padding: 14px; font-size: 15px; font-weight: 600; }

.how { display: grid; gap: 10px; counter-reset: how; }
.how > div { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.how > div::before { counter-increment: how; content: counter(how); width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--border-2); display: grid; place-items: center; font-size: 12px; }

/* ---------- toasts / modal ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: rgba(15,23,42,0.95); backdrop-filter: blur(10px); border: 1px solid var(--border-2); border-left: 3px solid var(--blue); color: var(--text); padding: 10px 14px; border-radius: var(--r-sm); max-width: 380px; font-size: 13.5px; box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
.toast.bad { border-left-color: var(--red); }
.toast.good { border-left-color: var(--emerald); }
.modal-bg { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.7); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal { background: #0f172a; border: 1px solid var(--border-2); border-radius: var(--r); width: 100%; max-width: 600px; padding: 22px 24px; max-height: 90vh; overflow: auto; }
.modal h2 { margin-bottom: 14px; font-size: 16px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
