/* Motor de farming — mini app de Telegram. Mismo lenguaje visual que PERP//GRID (trading/tg.css + retro.css):
 * fósforo ámbar sobre negro, bloques invertidos, sellos. Los estados se distinguen por trazo, forma y texto
 * (doble borde = pausa, discontinuo = atascada, tachado = sin respuesta), nunca solo por el color. */
:root {
  --bg: #100d08; --panel: #15110a; --panel-2: #1c160c; --hover: #221a0c; --line: #3a2c0c;
  --rule: #ffb000; --ink: #ffb000; --ink-2: #b07a06; --ink-3: #6b4c0a;
  --down: #ff5a36;
  --glow: 0 0 6px rgba(255, 176, 0, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; max-width: 100%; overflow-x: hidden; }
body {
  background: var(--bg); color: var(--ink); min-height: 100vh;
  font: 400 13px/1.45 "IBM Plex Mono", ui-monospace, "Cascadia Mono", monospace;
  font-feature-settings: "tnum" 1, "zero" 1; text-shadow: var(--glow);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: contain;
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .18) 0 1px, transparent 1px 3px),
    radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, .45) 100%);
}
button, input, select { font: inherit; color: inherit; text-shadow: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
[hidden] { display: none !important; }
.crt { min-height: 100vh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
.dim { color: var(--ink-2); } .faint { color: var(--ink-3); }

/* ---------- membrete ---------- */
.m-bar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: baseline; gap: 10px;
  padding: 10px 16px 8px; background: var(--bg); border-bottom: 3px solid var(--rule);
}
.m-bar .logo { font-family: "VT323", monospace; font-size: 26px; line-height: 1; letter-spacing: .04em; }
.m-bar .sub { font-size: 9.5px; color: var(--ink-2); letter-spacing: .12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.m-bar .clock { margin-left: auto; font-family: "VT323", monospace; font-size: 20px; color: var(--ink-2); }
.dev-tag { font-size: 10px; border: 1.5px dashed var(--ink); padding: 0 4px; letter-spacing: .1em; }

/* ---------- puerta (fuera de Telegram) ---------- */
.gate { padding: 64px 24px; text-align: center; }
.gate-big { font-family: "VT323", monospace; font-size: 34px; line-height: 1.05; margin: 0 0 12px; }
.gate-t { color: var(--ink-2); font-size: 12px; margin: 0; }

/* ---------- navegación ---------- */
.m-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bg); border-top: 3px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
}
.m-nav button {
  background: transparent; border: 0; color: var(--ink-2); padding: 10px 2px 12px; font-size: 10px; letter-spacing: .06em;
  display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer;
}
.m-nav button b { font-family: "VT323", monospace; font-size: 22px; font-weight: 400; line-height: 1; }
.m-nav button + button { border-left: 1px solid var(--line); }
.m-nav button.on { background: var(--rule); color: var(--bg); text-shadow: none; font-weight: 600; }
.view { display: none; }
body[data-view="estado"] #vEstado, body[data-view="manual"] #vManual, body[data-view="ajustes"] #vAjustes,
body[data-view="oro"] #vOro, body[data-view="control"] #vControl { display: block; }

/* ---------- piezas comunes ---------- */
.m-sect {
  margin: 16px 16px 8px; display: flex; align-items: center; gap: 10px; font-size: 10.5px; letter-spacing: .14em;
  color: var(--bg); background: var(--rule); padding: 4px 8px; text-shadow: none; font-weight: 600; white-space: nowrap; overflow: hidden;
}
.m-sect > span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.m-note { margin: 10px 16px 14px; color: var(--ink-2); font-size: 11.5px; line-height: 1.5; }
.empty { padding: 18px 16px; text-align: center; color: var(--ink-2); letter-spacing: .08em; font-size: 11.5px; }

/* ---------- libro por venue ---------- */
.m-ledger { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 3px solid var(--rule); }
.m-ledger > div { padding: 9px 16px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.m-ledger > div + div { border-left: 1px solid var(--line); }
.m-ledger span { display: block; font-size: 9.5px; letter-spacing: .12em; color: var(--ink-2); }
.m-ledger b { display: block; white-space: nowrap; font-family: "VT323", monospace; font-size: 28px; font-weight: 400; line-height: 1.05; }
.m-ledger small { font-size: 10.5px; color: var(--ink-2); }
.m-ledger .down b { text-decoration: line-through; color: var(--ink-3); }

/* ---------- tarjeta de activo ---------- */
.card { margin: 0 16px 10px; border: 1px solid var(--ink-2); background: var(--panel); min-width: 0; overflow: hidden; }
.card.paused { border: 3px double var(--ink); }
.card .head { display: flex; align-items: center; gap: 10px; padding: 8px 11px 6px; border-bottom: 1px solid var(--line); }
.card .sym { font-family: "VT323", monospace; font-size: 30px; line-height: .95; letter-spacing: .03em; }
.card .imb { margin-left: auto; text-align: right; font-size: 10px; letter-spacing: .08em; color: var(--ink-2); }
.card .imb b { display: block; font-family: "VT323", monospace; font-size: 22px; font-weight: 400; color: var(--ink); line-height: 1; }
.card .imb.off b::after { content: " ⚠"; }
.card .imb + .imb { margin-left: 14px; }
.pos { width: 100%; border-collapse: collapse; font-size: 12px; }
.pos th { font-size: 9.5px; letter-spacing: .1em; font-weight: 500; color: var(--ink-3); text-align: right; padding: 4px 11px 2px 4px; }
.pos th:first-child, .pos td:first-child { text-align: left; padding-left: 11px; }
.pos td { text-align: right; padding: 3px 11px 3px 4px; border-top: 1px dotted var(--line); white-space: nowrap; }
.pos td.ext-on { font-weight: 700; text-decoration: underline; text-decoration-style: double; }
.pause { display: flex; align-items: center; gap: 10px; padding: 8px 11px; border-top: 1px dashed var(--ink-2); }
.stamp {
  display: inline-block; font-family: "VT323", monospace; font-size: 16px; line-height: 1; letter-spacing: .08em;
  padding: 2px 5px 1px; border: 2px solid currentColor; transform: rotate(-3deg); text-shadow: none;
}
.pause .why { font-size: 11px; color: var(--ink-2); flex: 1; min-width: 0; }

/* ---------- operaciones ---------- */
.op { margin: 0 16px 8px; border: 1px solid var(--line); background: var(--panel); padding: 8px 11px; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; align-items: center; }
.op.stuck { border: 2px dashed var(--ink); }
.op .t { font-size: 12px; } .op .t b { font-weight: 600; }
.op .m { font-size: 10.5px; color: var(--ink-2); grid-column: 1; word-break: break-all; }
.op .act { grid-row: 1 / span 2; grid-column: 2; }

/* ---------- botones ---------- */
.btn, .btn-sm {
  background: var(--rule); color: var(--bg); border: 0; text-shadow: none; font-weight: 600; letter-spacing: .1em; cursor: pointer;
}
.btn { display: block; width: 100%; padding: 12px; font-size: 12px; }
.btn-sm { padding: 6px 9px; font-size: 10.5px; white-space: nowrap; }
.btn-sm.ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }
.btn:disabled, .btn-sm:disabled { opacity: .45; cursor: wait; }
.danger-zone { margin: 22px 16px 0; }
.btn-danger {
  display: block; width: 100%; padding: 15px 12px; cursor: pointer; font-size: 13px; font-weight: 700; letter-spacing: .12em;
  background: var(--down); color: #100d08; text-shadow: none; border: 3px double #100d08; outline: 2px solid var(--down);
}
.btn-danger:disabled { opacity: .5; cursor: wait; }
.danger-zone .m-note { margin: 8px 0 0; }

/* ---------- formularios ---------- */
.seg3 { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--ink-2); margin: 14px 16px 4px; }
.seg3 button { background: transparent; border: 0; color: var(--ink-2); padding: 9px 2px; font-size: 10.5px; letter-spacing: .08em; cursor: pointer; }
.seg3 button + button { border-left: 1px solid var(--ink-2); }
.seg3 button.on { background: var(--rule); color: var(--bg); text-shadow: none; font-weight: 600; }
.form, .set { margin: 0 16px; display: grid; gap: 8px; }
.form .m-note { margin: 6px 0 2px; }
.inp {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; padding: 0 10px;
  border: 1px solid var(--ink-2); color: var(--ink-2); font-size: 11px; letter-spacing: .06em; background: var(--bg);
}
.inp:focus-within { border-color: var(--ink); background: var(--panel-2); }
.inp input, .inp select { background: var(--bg); border: 0; outline: 0; color: var(--ink); font-size: 15px; text-align: right; width: 150px; min-width: 0; caret-color: var(--ink); }
.inp:focus-within input, .inp:focus-within select { background: var(--panel-2); }
.inp select { width: auto; max-width: 190px; font-size: 13px; cursor: pointer; }
.radio2 { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--ink-2); }
.radio2 label { position: relative; cursor: pointer; }
.radio2 label + label { border-left: 1px solid var(--ink-2); }
.radio2 input { position: absolute; opacity: 0; pointer-events: none; }
.radio2 span { display: block; padding: 9px 6px; text-align: center; font-size: 11px; letter-spacing: .08em; color: var(--ink-2); }
.radio2 small { font-size: 9.5px; letter-spacing: .04em; }
.radio2 input:checked + span { background: var(--rule); color: var(--bg); text-shadow: none; font-weight: 600; }
.radio2 input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -3px; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 11px; letter-spacing: .08em; color: var(--ink-2); padding: 4px 0; }
.chk input { width: 18px; height: 18px; accent-color: var(--ink); }
.hint { font-size: 11px; color: var(--ink-2); min-height: 1em; padding: 0 2px; }

/* ---------- resultado ---------- */
.result { margin: 12px 16px; border: 2px solid var(--ink); padding: 9px 11px; font-size: 12px; line-height: 1.5; background: var(--panel); white-space: pre-wrap; word-break: break-word; }
.result.err { border-style: dashed; }
.result .stamp { margin-right: 8px; }

/* ---------- oro: gráficos SVG sin librerías (sin estilos en línea: la CSP no los admite) ---------- */
.asset-pick { margin: 14px 16px 0; }
.chart { margin: 0 16px 10px; border: 1px solid var(--ink-2); background: var(--panel); padding: 8px 10px 6px; min-width: 0; }
.chart-t { font-size: 10px; letter-spacing: .12em; color: var(--ink-2); margin-bottom: 4px; }
.chart svg { display: block; width: 100%; height: 90px; background: var(--bg); }
.chart .legend { display: flex; gap: 14px; font-size: 10px; color: var(--ink-2); margin-top: 4px; letter-spacing: .06em; }
.ln { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ink); vertical-align: middle; margin-right: 5px; }
.ln.dash { border-top-style: dashed; }
.axis { display: flex; justify-content: space-between; font-size: 10px; color: var(--ink-2); margin-top: 3px; }
.bar { fill: var(--ink-2); }
.bar.hot { fill: var(--ink); }
.thr { stroke: var(--ink); stroke-width: 3; stroke-dasharray: 5 3; }
.nowline { stroke: var(--ink); stroke-width: 1.5; }
.gridline { stroke: var(--line); stroke-width: 1; }
.poly { fill: none; stroke: var(--ink); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.poly.dash { stroke-dasharray: 4 3; }
.prog-bg { fill: var(--panel-2); stroke: var(--ink-2); stroke-width: 1; }
.prog-fg { fill: var(--ink); }
.prog-fg.neg { fill: var(--down); }
.prog-tgt { stroke: var(--ink); stroke-width: 3; }
.cyc { margin: 0 16px 8px; border: 1px solid var(--line); background: var(--panel); padding: 8px 11px; font-size: 12px; line-height: 1.55; }
.cyc.open { border: 2px solid var(--ink); }
.cyc .row { display: flex; justify-content: space-between; gap: 8px; }
.cyc .row span:first-child { color: var(--ink-2); font-size: 10.5px; letter-spacing: .08em; }
.cyc svg { display: block; width: 100%; height: 14px; margin: 6px 0 2px; }
.tbl { width: calc(100% - 32px); margin: 0 16px 10px; border-collapse: collapse; font-size: 11px; }
.tbl th { font-size: 9.5px; letter-spacing: .08em; font-weight: 500; color: var(--ink-3); text-align: right; padding: 4px 4px 3px; border-bottom: 1px solid var(--ink-2); }
.tbl td { text-align: right; padding: 4px 4px; border-top: 1px dotted var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl tr.openrow td { font-weight: 700; }
.tbl td.neg { text-decoration: line-through; text-decoration-style: wavy; }
.ctl-state { padding: 10px 12px; font-size: 12.5px; line-height: 1.6; }
.ctl-state .big { font-family: "VT323", monospace; font-size: 28px; line-height: 1; }
.ctl-btns { margin: 12px 16px 0; display: grid; gap: 10px; }
