/* ==========================================================================
   ALBION BLACK MARKET TERMINAL
   Oro envejecido y tipografía romana de Albion + rejilla de terminal financiera.
   Todas las medidas de texto están en rem: los botones A− / A / A+ cambian el
   tamaño base de <html> y toda la interfaz escala a la vez.
   Todos los colores son variables: el pergamino del detalle las redefine.
   ========================================================================== */
:root {
  color-scheme: dark;
  --ink-0: #0a0907;
  --ink-1: #13110d;
  --ink-2: #1b1811;
  --ink-3: #252016;
  --ink-4: #2f281c;
  --rule: #3a3123;
  --rule-strong: #54452c;
  --gold: #d8ad55;
  --gold-bright: #f4d27c;
  --gold-dim: #a8884f;
  --gold-glow: rgba(216, 173, 85, .22);
  --text: #efe7d4;
  --text-dim: #c3b597;
  --text-faint: #8f8369;
  --profit: #6ee39b;
  --profit-bg: rgba(110, 227, 155, .12);
  --loss: #ff6b5e;
  --loss-bg: rgba(255, 107, 94, .12);
  --amber: #f3b54f;
  --amber-bg: rgba(243, 181, 79, .12);
  --azure: #8cc0ea;
  --azure-bg: rgba(140, 192, 234, .14);
  --crimson: #8e1b1b;
  --crimson-bright: #d24a3c;
  --f-display: 'Cinzel', 'Trajan Pro', 'Times New Roman', Georgia, serif;
  --f-mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
  --f-ui: 'IBM Plex Sans Condensed', 'Segoe UI', 'Arial Narrow', sans-serif;
  --radius: 3px;
}

* { box-sizing: border-box; }
html { font-size: 17px; background: var(--ink-0); }
body {
  margin: 0;
  padding-bottom: 2.4rem;
  font: 1rem/1.5 var(--f-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 520px at 50% -120px, rgba(142, 27, 27, .22), transparent 70%),
    radial-gradient(900px 600px at 100% 0%, rgba(216, 173, 85, .07), transparent 60%),
    var(--ink-0);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--gold); color: var(--ink-0); }
h1, h2, h3 { font-family: var(--f-display); font-weight: 700; letter-spacing: .06em; }
h1 { margin: 0; }
h2 {
  display: flex; align-items: center; gap: .7rem;
  margin: 0 0 1rem; font-size: 1.1rem; text-transform: uppercase; color: var(--gold);
}
h2::before { content: "◆"; font-size: .6rem; color: var(--gold-dim); }
h2::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--rule-strong), transparent); }
h3 { margin: 1.2rem 0 .6rem; font-size: .95rem; text-transform: uppercase; color: var(--gold); letter-spacing: .08em; }
code { font-family: var(--f-mono); font-size: .8rem; color: var(--text-faint); }
b { color: var(--text); font-weight: 600; }
a { color: var(--gold-bright); }
p { margin: .6rem 0; }
.muted, .dim { color: var(--text-dim); }
.small { font-size: .88rem; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- cabecera */
.top {
  position: relative;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem 1.5rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(180deg, #17120c, #0e0c09);
  border-bottom: 1px solid var(--rule-strong);
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold-dim) 15%, var(--gold) 50%, var(--gold-dim) 85%, transparent);
  opacity: .5;
}
.brand { display: flex; align-items: center; gap: 1rem; }
.crest { width: 3.2rem; height: 3.6rem; flex: none; filter: drop-shadow(0 0 10px rgba(216, 173, 85, .25)); }
.crest-shield { fill: var(--crimson); stroke: var(--gold); stroke-width: 2.2; }
.crest-inner { fill: #1a0d0b; stroke: var(--gold-dim); stroke-width: 1; }
.crest-scale { stroke: var(--gold-bright); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.crest-scale path { fill: rgba(244, 210, 124, .18); }
.crest-scale circle { fill: var(--gold-bright); stroke: none; }
.eyebrow { font: 600 .75rem/1 var(--f-mono); letter-spacing: .18em; text-transform: uppercase; color: var(--crimson-bright); margin-bottom: .35rem; }
.brand h1 {
  font-size: 1.85rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; line-height: 1.05;
  background: linear-gradient(180deg, #fbe3a2 0%, var(--gold) 55%, #9a7533 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand .sub { font-size: .9rem; color: var(--text-dim); margin-top: .2rem; }
.top-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .9rem; }
.refresh-info { font: .82rem/1.55 var(--f-mono); color: var(--text-dim); min-width: 15rem; }
.refresh-info b { color: var(--gold-bright); font-weight: 500; }
.clock { font: 600 1.35rem/1 var(--f-mono); color: var(--gold-bright); letter-spacing: .05em; margin-bottom: .25rem; }
.clock .dim { font-size: .7rem; letter-spacing: .2em; }

/* tamaño de letra */
.textsize { display: flex; align-items: center; gap: .3rem; padding: .25rem .4rem; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--ink-2); }
.textsize-label { font-size: .78rem; color: var(--text-dim); padding: 0 .3rem; }
.textsize button { padding: .45rem .6rem; min-width: 2.4rem; font: 700 .95rem/1 var(--f-ui); text-transform: none; letter-spacing: 0; }
.textsize button[data-size="1"] { font-size: 1.15rem; }
.textsize button[data-size="-1"] { font-size: .8rem; }
.textsize button.active { border-color: var(--gold); }

/* ---------------------------------------------------------------- controles */
label { display: flex; flex-direction: column; gap: .35rem; font: 600 .88rem/1.25 var(--f-ui); color: var(--text-dim); }
label.chk { flex-direction: row; align-items: center; gap: .55rem; color: var(--text); font-weight: 500; font-size: .95rem; cursor: pointer; }
input, select {
  font: 1rem var(--f-mono); color: var(--text);
  background: var(--ink-3); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: .55rem .7rem; min-height: 2.6rem; min-width: 0;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45);
  transition: border-color .15s, box-shadow .15s;
}
select { font-family: var(--f-ui); font-size: .98rem; padding-right: 2rem; cursor: pointer; }
input::placeholder { color: var(--text-faint); font-style: italic; }
input:hover, select:hover { border-color: var(--gold-dim); }
input:focus, select:focus { outline: none; border-color: var(--gold); box-shadow: inset 0 1px 3px rgba(0, 0, 0, .45), 0 0 0 3px var(--gold-glow); }
input:invalid { border-color: var(--loss); }
input[type=checkbox] { accent-color: var(--gold); width: 1.15rem; height: 1.15rem; min-height: 0; box-shadow: none; cursor: pointer; }
fieldset:disabled { opacity: .45; }

button, a.btn {
  font: 600 .9rem/1.1 var(--f-ui); letter-spacing: .04em;
  color: var(--gold-bright); background: linear-gradient(180deg, var(--ink-4), var(--ink-2));
  border: 1px solid var(--rule-strong); border-radius: var(--radius);
  padding: .65rem 1rem; cursor: pointer; min-height: 2.6rem;
  box-shadow: inset 0 1px 0 rgba(255, 230, 170, .06), 0 1px 0 rgba(0, 0, 0, .5);
  transition: border-color .15s, color .15s, filter .15s;
}
button:hover, a.btn:hover { border-color: var(--gold); color: #fff3d0; }
button:active { transform: translateY(1px); }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
button.primary, a.btn.primary {
  color: #1b1206; border-color: #e7c06a; text-transform: uppercase; letter-spacing: .06em;
  background: linear-gradient(180deg, #f6d686 0%, #d6a94c 48%, #a87a2f 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -2px 0 rgba(90, 55, 10, .35), 0 0 18px rgba(216, 173, 85, .25);
  padding: .75rem 1.3rem; font-size: .95rem; min-height: 2.9rem;
}
button.primary:hover, a.btn.primary:hover { filter: brightness(1.08); color: #1b1206; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
button:disabled { opacity: .55; cursor: progress; }
.btn-glyph { display: inline-block; margin-right: .3rem; }
button:disabled .btn-glyph { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.small-btn { padding: .45rem .75rem; font-size: .85rem; min-height: 2.2rem; }

/* ---------------------------------------------------------------- banner demo */
.demo-banner {
  display: flex; align-items: center; justify-content: center; gap: .8rem; flex-wrap: wrap;
  padding: .6rem 1rem; color: #fde8e4; font-weight: 600; font-size: .95rem; text-align: center;
  background: repeating-linear-gradient(-45deg, #5d1010 0 14px, #741616 14px 28px);
  border-bottom: 1px solid var(--crimson-bright);
}
.demo-banner span { font-family: var(--f-display); letter-spacing: .16em; text-transform: uppercase; color: #ffd27a; }
.demo-word { color: var(--crimson-bright) !important; letter-spacing: .1em; }

/* ---------------------------------------------------------------- cinta de cotizaciones */
.ticker {
  display: flex; align-items: stretch; height: 2.4rem; margin-top: 4px;
  background: #0c0a07; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  font: .9rem/2.4rem var(--f-mono); overflow: hidden;
}
.ticker-label {
  flex: none; padding: 0 1.6rem 0 1rem; font: 700 .8rem/2.4rem var(--f-display); letter-spacing: .16em; text-transform: uppercase;
  color: #1b1206; background: linear-gradient(180deg, #e8c46f, #b8893a);
  clip-path: polygon(0 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
}
.ticker-viewport { flex: 1; overflow: hidden; position: relative; mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent); }
.ticker-track { display: inline-flex; white-space: nowrap; will-change: transform; }
.ticker-track.run { animation: ticker var(--ticker-dur, 60s) linear infinite; }
.ticker-viewport:hover .ticker-track { animation-play-state: paused; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.tick { padding: 0 1.6rem; border-right: 1px solid var(--rule); cursor: pointer; }
.tick:hover { background: var(--ink-2); }
.tick .t-name { color: var(--text); }
.tick .t-route { color: var(--text-dim); }
.tick .t-up { color: var(--profit); }
.tick .t-down { color: var(--loss); }
.tick .t-seal { color: var(--gold-bright); }

/* ---------------------------------------------------------------- indicadores */
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 1px; background: var(--rule); border-bottom: 1px solid var(--rule); }
.kpi { display: flex; flex-direction: column; gap: .15rem; padding: .8rem 1.2rem; background: linear-gradient(180deg, var(--ink-2), var(--ink-1)); min-width: 0; }
.kpi-label { font: 700 .75rem/1.2 var(--f-display); letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.kpi-value { font: 600 1.55rem/1.2 var(--f-mono); color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: .5rem; }
.kpi-sub { font-size: .82rem; line-height: 1.35; color: var(--text-dim); overflow-wrap: anywhere; }
.kpi-seal .kpi-value { color: var(--gold-bright); }
.kpi-value.pos { color: var(--profit); }
.kpi-value.warn { color: var(--amber); font-size: 1.15rem; }
.pulse { width: .6rem; height: .6rem; border-radius: 50%; background: var(--text-faint); flex: none; }
.pulse.on { background: var(--profit); box-shadow: 0 0 0 0 rgba(110, 227, 155, .6); animation: pulse 2s infinite; }
.pulse.off { background: var(--loss); }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(110, 227, 155, 0); } 100% { box-shadow: 0 0 0 0 rgba(110, 227, 155, 0); } }

/* ---------------------------------------------------------------- barra rápida */
.quickbar {
  display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; align-items: flex-end; padding: .9rem 1.5rem;
  background: var(--ink-1); border-bottom: 1px solid var(--rule);
}
.quickbar input:not([type=checkbox]) { width: 15rem; font-size: 1.05rem; }
.quickbar label.chk { padding-bottom: .6rem; }
#save-state { font: .85rem var(--f-mono); margin-left: auto; align-self: center; color: var(--text-dim); }

/* ---------------------------------------------------------------- pestañas */
.tabs { display: flex; align-items: flex-end; gap: 3px; padding: 1.1rem 1.5rem 0; overflow-x: auto; }
.tabs button {
  display: flex; align-items: center; gap: .6rem; white-space: nowrap;
  padding: .8rem 1.2rem; border-bottom: none; border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text-dim); background: var(--ink-1); border-color: var(--rule); box-shadow: none;
  font-size: 1rem; letter-spacing: .02em; min-height: 0;
}
.tabs button:hover { color: var(--text); background: var(--ink-2); }
.tabs button.active {
  color: var(--gold-bright); background: var(--ink-2);
  border: 1px solid var(--rule-strong); border-bottom-color: var(--ink-2);
  position: relative; top: 1px;
  box-shadow: inset 0 3px 0 var(--gold);
}
.numeral { font: 700 1rem/1 var(--f-display); color: var(--gold-dim); min-width: 1.4rem; text-align: center; }
.tabs button.active .numeral { color: var(--gold); }
.tabs-hint { margin-left: auto; padding: 0 0 .7rem 1rem; font: .78rem var(--f-mono); color: var(--text-faint); white-space: nowrap; }

main { padding: 0 1.5rem 1.8rem; }
.tab { position: relative; background: var(--ink-2); border: 1px solid var(--rule-strong); padding: 1.3rem; }

/* esquinas tipo marco */
.tab::before, .tab::after, .card::before, .card::after {
  content: ""; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border-color: var(--gold-dim); border-style: solid;
}
.tab::before, .card::before { top: -1px; left: -1px; border-width: 2px 0 0 2px; }
.tab::after, .card::after { bottom: -1px; right: -1px; border-width: 0 2px 2px 0; }

.card { position: relative; background: var(--ink-1); border: 1px solid var(--rule); padding: 1.3rem; margin-bottom: 1.2rem; }
.card label { margin-bottom: .9rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr)); gap: 1.2rem; margin-bottom: 1.2rem; }
.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.row .grow { flex: 1 1 14rem; }
.row.buttons { margin-top: .9rem; }
fieldset { border: 1px solid var(--rule); border-radius: var(--radius); padding: .7rem 1rem .4rem; margin: .9rem 0; background: rgba(0, 0, 0, .15); }
legend { font: 700 .82rem var(--f-display); letter-spacing: .08em; text-transform: uppercase; color: var(--gold); padding: 0 .5rem; }
.chips { display: flex; flex-wrap: wrap; gap: .6rem; }
.chips label {
  flex-direction: row; align-items: center; gap: .45rem; font-size: .95rem; font-weight: 500;
  color: var(--text); border: 1px solid var(--rule-strong); border-radius: 999px; padding: .4rem .9rem; background: var(--ink-3); cursor: pointer; margin: 0;
}
.chips label:has(input:checked) { border-color: var(--gold); background: rgba(216, 173, 85, .12); color: var(--gold-bright); }

/* ---------------------------------------------------------------- lista «listo para operar» */
.checklist {
  display: grid; grid-template-columns: auto repeat(4, minmax(0, 1fr)); gap: .6rem; align-items: stretch;
  margin-bottom: 1.2rem;
}
.cl-head { display: flex; flex-direction: column; justify-content: center; padding: 0 .8rem 0 .2rem; }
.cl-title { font: 700 .95rem/1.2 var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--gold); }
.cl-count { font: 600 .9rem var(--f-mono); color: var(--text-dim); margin-top: .2rem; }
.cl-step {
  display: flex; align-items: flex-start; gap: .75rem; padding: .7rem .8rem;
  background: var(--ink-1); border: 1px solid var(--rule); border-left-width: 4px; border-radius: var(--radius); min-width: 0;
}
.cl-step.ok { border-left-color: var(--profit); }
.cl-step.todo { border-left-color: var(--amber); background: linear-gradient(90deg, var(--amber-bg), var(--ink-1) 60%); }
.cl-mark {
  flex: none; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: 50%;
  font: 700 .95rem var(--f-mono); border: 2px solid currentColor;
}
.cl-step.ok .cl-mark { color: var(--profit); }
.cl-step.todo .cl-mark { color: var(--amber); }
.cl-body { flex: 1; min-width: 0; }
.cl-name { font-weight: 600; font-size: .95rem; color: var(--text); }
.cl-text { font-size: .88rem; color: var(--text-dim); line-height: 1.4; }
.cl-btn { margin-top: .5rem; }

/* ---------------------------------------------------------------- filtros */
.filters {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .9rem 1rem; align-items: end;
  padding: 1rem; margin-bottom: 1rem; background: var(--ink-1); border: 1px solid var(--rule); border-radius: var(--radius);
}
.filters select { width: 100%; }
fieldset.tiers { display: flex; gap: .9rem; margin: 0; padding: .45rem .8rem; grid-column: span 1; min-height: 2.6rem; align-items: center; }
fieldset.tiers legend { font-family: var(--f-ui); font-weight: 600; font-size: .88rem; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
fieldset.tiers label { flex-direction: row; align-items: center; gap: .35rem; color: var(--text); font: 600 .98rem var(--f-mono); cursor: pointer; }
.filters label.chk { padding-bottom: .55rem; }
.legend { font-size: .9rem; color: var(--text-dim); margin: .4rem 0 .8rem; line-height: 2.2; }

.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; margin: .2rem 0 .5rem; }
#opps-summary { font-size: .95rem; color: var(--text-dim); }
.sum-main { font: 700 1.15rem var(--f-mono); color: var(--gold-bright); }
.sum-sep { margin: 0 .5rem; color: var(--text-faint); }
.segmented { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.segmented button { border: none; border-radius: 0; box-shadow: none; background: var(--ink-1); color: var(--text-dim); min-height: 2.4rem; }
.segmented button + button { border-left: 1px solid var(--rule-strong); }
.segmented button.active { background: rgba(216, 173, 85, .16); color: var(--gold-bright); }

/* ---------------------------------------------------------------- tablas */
.table-wrap { overflow: auto; border: 1px solid var(--rule); background: var(--ink-1); max-height: 72vh; }
table.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .95rem; }
table.grid th, table.grid td { padding: .65rem .85rem; border-bottom: 1px solid rgba(84, 69, 44, .5); text-align: left; white-space: nowrap; vertical-align: top; }
table.grid th {
  position: sticky; top: 0; z-index: 1;
  font: 700 .8rem/1.25 var(--f-ui); text-transform: uppercase; letter-spacing: .06em;
  color: var(--gold); background: #17140e; border-bottom: 2px solid var(--gold-dim);
  cursor: pointer; user-select: none;
}
table.grid tr.group-row th { top: 0; height: 2.1rem; padding-top: 0; padding-bottom: 0; line-height: 2.1rem; cursor: default; text-align: center; font-family: var(--f-display); font-size: .78rem; color: var(--gold-bright); background: #1d1810; border-bottom: 1px solid var(--rule-strong); border-left: 1px solid var(--rule-strong); }
table.grid tr.group-row + tr th { top: 2.1rem; }
table.grid th:hover { color: var(--gold-bright); }
table.grid th.sorted-asc, table.grid th.sorted-desc { color: var(--gold-bright); }
table.grid th.sorted-asc::after { content: " ▲"; } table.grid th.sorted-desc::after { content: " ▼"; }
table.grid.compact th { cursor: default; }
table.grid tbody tr:nth-child(even) td { background: rgba(255, 235, 190, .022); }
table.grid tbody tr:hover td { background: rgba(216, 173, 85, .08); }
table.grid tbody tr:hover td:first-child, table.grid tbody tr:focus td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
#opps-table tbody tr { cursor: pointer; }
#opps-table tbody tr:focus { outline: none; }
#opps-table tbody tr:focus td { background: rgba(216, 173, 85, .1); }
#opps-table td.empty { text-align: center; padding: 2.5rem 1rem; font-size: 1.05rem; white-space: normal; }

/* vista resumida */
#opps-table.view-simple td { padding-top: .8rem; padding-bottom: .8rem; }
.item-name { font-weight: 600; font-size: 1.02rem; color: var(--text); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .3rem; }
.chip { display: inline-block; padding: .1rem .5rem; border: 1px solid var(--rule-strong); border-radius: var(--radius); font: 600 .8rem/1.4 var(--f-mono); color: var(--text-dim); background: var(--ink-3); }
.chip-tier { color: var(--gold-bright); border-color: var(--gold-dim); }
.route { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; font-size: 1rem; }
.route .arrow { color: var(--gold); font-weight: 700; margin: 0 .2rem; }
.price { font: 600 1.05rem var(--f-mono); color: var(--text); }
.net { font: 700 1.15rem var(--f-mono); }
.sub { font-size: .82rem; color: var(--text-dim); margin-top: .2rem; font-family: var(--f-ui); }
.sub-warn { color: var(--amber); font-size: .82rem; }

.num { text-align: right !important; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.num .sub, .num .sub-warn { font-family: var(--f-ui); }
.pos { color: var(--profit); font-weight: 600; }
.neg { color: var(--loss); }

/* ---------------------------------------------------------------- sellos y etiquetas */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: var(--radius);
  font: 600 .8rem/1.5 var(--f-ui); letter-spacing: .02em; white-space: nowrap; border: 1px solid transparent;
}
.st-confirmada { color: #1b1206; border-color: #f0cb75; background: linear-gradient(180deg, #f6d686, #c99a42); box-shadow: 0 0 10px rgba(216, 173, 85, .35); }
.st-confirmada::before { content: "✦"; }
.st-manual { color: var(--azure); background: var(--azure-bg); border-color: rgba(140, 192, 234, .45); }
.st-detectada { color: var(--amber); background: var(--amber-bg); border-color: rgba(243, 181, 79, .45); }
.st-no_rentable, .st-no_verificable { color: var(--text-dim); border-color: var(--rule-strong); background: transparent; }
.fr-reciente, .fr-antiguo, .fr-desconocido { background: transparent; border-color: transparent; padding-left: 0; padding-right: 0; font-family: var(--f-mono); font-size: .88rem; }
.fr-reciente { color: var(--profit); } .fr-antiguo { color: var(--loss); } .fr-desconocido { color: var(--text-faint); }
.fr-reciente::before, .fr-antiguo::before, .fr-desconocido::before { content: "●"; font-size: .6rem; }
.risk-alto { color: #ffe1dc; background: var(--crimson); border-color: var(--crimson-bright); }
.risk-bajo { color: var(--profit); background: var(--profit-bg); border-color: rgba(110, 227, 155, .35); }
.risk-desconocido, .risk-n\/a { color: var(--text-dim); border-color: var(--rule-strong); }
.used { color: #1b1206; background: var(--gold); border-color: var(--gold-bright); }
.demo-badge { color: #fff4d6; background: repeating-linear-gradient(-45deg, #6d1212 0 6px, #8e1b1b 6px 12px); border-color: #5d0f0f; letter-spacing: .08em; text-transform: uppercase; }
.warn-list { margin: .5rem 0; padding-left: 1.4rem; color: var(--amber); }
.warn-list li { margin: .25rem 0; }
.warn-list li::marker { content: "✕  "; color: var(--loss); }
.error { background: var(--loss-bg); color: var(--loss); border: 1px solid rgba(255, 107, 94, .4); padding: .7rem .9rem; margin: .6rem 0; font-size: .95rem; }
.logs {
  max-height: 30rem; overflow: auto; margin: 0; padding: 1rem;
  font: .85rem/1.6 var(--f-mono); color: #c4dfb0; background: #070605; border: 1px solid var(--rule);
  white-space: pre-wrap;
}
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.2rem; font-size: .98rem; margin: 0; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(20rem, 100%), 1fr)); gap: 1.2rem; }
.big { font: 700 1.4rem var(--f-mono); }

/* ---------------------------------------------------------------- pergamino de operación */
.drawer { position: fixed; inset: 0; z-index: 30; display: flex; justify-content: flex-end; background: rgba(5, 4, 3, .72); backdrop-filter: blur(2px); }
.drawer-inner {
  --ink-1: #efe3c6; --ink-2: #e6d7b4; --ink-3: #f8f1df; --ink-4: #ddcba3;
  --rule: #c2a979; --rule-strong: #9c8150;
  --gold: #7a5212; --gold-bright: #5e3c0c; --gold-dim: #8a6d3c; --gold-glow: rgba(122, 82, 18, .2);
  --text: #23190d; --text-dim: #4f3f27; --text-faint: #7a6748;
  --profit: #17703a; --profit-bg: rgba(23, 112, 58, .12);
  --loss: #a3241a; --loss-bg: rgba(163, 36, 26, .1);
  --amber: #8a4f05; --amber-bg: rgba(138, 79, 5, .1);
  --azure: #1d4f80; --azure-bg: rgba(29, 79, 128, .1);
  color-scheme: light;
  position: relative; width: min(64rem, 100%); height: 100%; overflow-y: auto;
  padding: 2rem 2.2rem 3rem; color: var(--text);
  background:
    radial-gradient(ellipse at center, rgba(255, 250, 235, .55), transparent 70%),
    radial-gradient(ellipse at 0 0, rgba(120, 84, 34, .22), transparent 40%),
    radial-gradient(ellipse at 100% 100%, rgba(120, 84, 34, .26), transparent 45%),
    #ecdfc0;
  box-shadow: -10px 0 40px rgba(0, 0, 0, .6), inset 0 0 80px rgba(110, 76, 30, .3);
  border-left: 3px double #8f7444;
  animation: unroll .22s ease-out;
}
@keyframes unroll { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-inner h2 { font: 900 1.6rem/1.25 var(--f-display); color: #36240e; text-transform: none; letter-spacing: .02em; flex-wrap: wrap; padding-right: 3rem; }
.drawer-inner h2::before { content: "❦"; font-size: 1.3rem; color: var(--crimson); }
.drawer-inner h2::after { display: none; }
.drawer-inner h3 { color: #5e3c0c; }
.drawer-inner .card { background: rgba(255, 250, 235, .5); border-color: var(--rule); }
.drawer-inner .table-wrap { background: rgba(255, 250, 235, .55); max-height: none; }
.drawer-inner table.grid th { background: #e0cea6; color: #4f3a16; border-bottom-color: var(--rule-strong); }
.drawer-inner table.grid tbody tr:nth-child(even) td { background: rgba(120, 84, 34, .05); }
.drawer-inner .st-confirmada { color: #fff4d6; background: radial-gradient(circle at 35% 30%, #c0392b, #7a1414); border-color: #5d0f0f; box-shadow: 0 1px 3px rgba(0, 0, 0, .35); }
.drawer-inner .used { color: #fff4d6; background: #5e3c0c; border-color: #5e3c0c; }
.drawer-inner .risk-alto { color: #fff; background: #8e1b1b; }
.drawer-inner input, .drawer-inner select { box-shadow: inset 0 1px 2px rgba(80, 55, 20, .25); }
.drawer-inner button { color: #36240e; background: linear-gradient(180deg, #f5e9cb, #dcc79a); border-color: #9c8150; box-shadow: none; }
.drawer-inner button:hover { border-color: #5e3c0c; color: #1b1206; }
.drawer-head { font: .88rem var(--f-mono); color: var(--text-dim); margin-bottom: 1rem; padding-bottom: .9rem; border-bottom: 1px solid var(--rule); }
.close { position: absolute; right: 1.2rem; top: 1.1rem; font: 400 1.6rem/1 var(--f-display); padding: .3rem .8rem; z-index: 2; }

/* resumen de la orden */
.order-summary {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1.1fr; align-items: stretch; gap: .6rem;
  margin: .4rem 0 1.2rem; padding: 1rem; border: 2px solid var(--rule-strong); border-radius: var(--radius);
  background: rgba(255, 250, 235, .6);
}
.order-summary.no-go { grid-template-columns: 1fr; }
.os-step { display: flex; flex-direction: column; gap: .2rem; padding: .3rem .4rem; }
.os-k { font: 700 .82rem var(--f-display); text-transform: uppercase; letter-spacing: .06em; color: var(--gold); }
.os-v { font: 700 1.35rem/1.2 var(--f-mono); color: var(--text); }
.os-s { font-size: .88rem; color: var(--text-dim); }
.os-result { background: rgba(23, 112, 58, .08); border-radius: var(--radius); padding: .5rem .8rem; }
.no-go .os-result { background: rgba(163, 36, 26, .08); }
.os-result .os-v { font-size: 1.7rem; }
.os-arrow { align-self: center; font: 700 1.6rem var(--f-display); color: var(--gold-dim); }

/* ---------------------------------------------------------------- barra de estado */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; height: 2rem; overflow: hidden;
  font: .82rem/2rem var(--f-mono); color: var(--text-dim);
  background: #0d0b08; border-top: 1px solid var(--gold-dim);
}
.statusbar .seg { padding: 0 1rem; border-right: 1px solid var(--rule); white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.statusbar .seg b { color: var(--gold-bright); font-weight: 600; letter-spacing: .1em; }
.statusbar .sb-right { margin-left: auto; border-right: none; border-left: 1px solid var(--rule); color: var(--gold); letter-spacing: .12em; font-weight: 600; }
.statusbar .sb-right.demo { color: #fff; background: var(--crimson); }
.led { width: .5rem; height: .5rem; border-radius: 50%; background: var(--text-faint); }
.led.on { background: var(--profit); box-shadow: 0 0 6px var(--profit); }
.led.off { background: var(--loss); box-shadow: 0 0 6px var(--loss); }

/* ---------------------------------------------------------------- barras de desplazamiento */
* { scrollbar-width: thin; scrollbar-color: var(--rule-strong) transparent; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--rule-strong); border: 2px solid var(--ink-1); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- adaptable */
@media (max-width: 1250px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tabs-hint { display: none; }
  .checklist { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cl-head { grid-column: 1 / -1; flex-direction: row; align-items: baseline; gap: .8rem; padding: 0; }
}
@media (max-width: 900px) {
  .order-summary { grid-template-columns: 1fr; }
  .os-arrow { transform: rotate(90deg); justify-self: center; line-height: 1; }
}
@media (max-width: 640px) {
  .top, .quickbar, main { padding-left: 1rem; padding-right: 1rem; }
  .tabs { padding-left: 1rem; padding-right: 1rem; }
  .brand h1 { font-size: 1.35rem; }
  .crest { width: 2.5rem; height: 2.8rem; }
  .top-controls { width: 100%; }
  .top-controls label { flex: 1 1 9rem; }
  .top-controls .primary { flex: 1 1 100%; }
  .refresh-info { min-width: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: .6rem .9rem; }
  .kpi-value { font-size: 1.2rem; }
  .quickbar label { flex: 1 1 100%; }
  .quickbar input:not([type=checkbox]) { width: 100%; }
  .quickbar label.chk { flex: 0 0 auto; }
  .checklist { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
  .drawer-inner { padding: 1.4rem 1rem 3rem; }
  .statusbar .seg:nth-child(n+3):not(.sb-right) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ticker-track.run { animation: none; }
  .ticker-viewport { overflow-x: auto; }
  .pulse.on, .drawer-inner, button:disabled .btn-glyph { animation: none; }
}

/* la vista resumida cabe sin desplazamiento lateral en pantallas normales */
#opps-table.view-simple td { white-space: normal; }
#opps-table.view-simple .price, #opps-table.view-simple .net, #opps-table.view-simple .badge { white-space: nowrap; }
#opps-table.view-simple .c-item { min-width: 11.5rem; }
#opps-table.view-simple .c-route { min-width: 10rem; }
#opps-table.view-simple .sub, #opps-table.view-simple .sub-warn { display: block; max-width: 12rem; margin-left: auto; }
#opps-table.view-simple td:not(.num) .sub { margin-left: 0; }

/* beneficio neto con costes aún desconocidos */
.net.provisional { color: var(--amber); }
#opps-table.view-simple .fr-reciente, #opps-table.view-simple .fr-antiguo, #opps-table.view-simple .fr-desconocido { white-space: normal; }
#opps-table td.empty .small-btn { margin-top: .8rem; }
#opps-table td.empty { line-height: 1.7; }

/* ámbito: grupos, niveles, encantamientos y atajos */
.scope { display: flex; flex-direction: column; gap: .7rem; padding: 1rem; margin-bottom: .9rem; background: var(--ink-1); border: 1px solid var(--rule); border-radius: var(--radius); }
.scope-row { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; }
.scope-label { font: 700 .82rem var(--f-display); text-transform: uppercase; letter-spacing: .08em; color: var(--gold); min-width: 7rem; }
.chips-compact label { padding: .3rem .7rem; font-family: var(--f-mono); font-weight: 600; }
.scope-presets .small-btn { min-height: 2.1rem; }
.scope-count { font-size: .88rem; color: var(--text-dim); margin-left: auto; }
.filters .f-search { grid-column: span 2; }
.filters .f-search input { width: 100%; }

/* lista de comprobación */
.check-head { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1.2rem; align-items: end; margin-bottom: 1rem; }
.check-intro p { margin: 0; color: var(--text-dim); line-height: 1.6; }
.check-controls { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: flex-end; }
.ck-progress { margin: .4rem 0 .6rem; }
.ck-bar { height: .55rem; background: var(--ink-3); border: 1px solid var(--rule); border-radius: 999px; overflow: hidden; }
.ck-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright)); transition: width .4s; }
.ck-stats { margin-top: .5rem; font-size: .95rem; color: var(--text-dim); }
.ck-pending { color: var(--text); border-color: var(--rule-strong); }
#ck-table td { white-space: normal; }
#ck-table .price, #ck-table .maxbuy, #ck-table .net, #ck-table .badge { white-space: nowrap; }
#ck-table .maxbuy { font: 700 1.2rem var(--f-mono); color: var(--gold-bright); }
#ck-table .ck-how .small-btn { margin-top: .4rem; }
#ck-table tr.ck-rentable td { background: rgba(110, 227, 155, .07); }
#ck-table tr.ck-rentable td:first-child { box-shadow: inset 4px 0 0 var(--profit); }
#ck-table tr.ck-no_rentable td { opacity: .55; }
#ck-table tr.ck-no_rentable .item-name { text-decoration: line-through; }
@media (max-width: 900px) { .check-head { grid-template-columns: 1fr; } }
#ck-table .c-item { max-width: 15rem; }
#ck-table th:nth-child(5) { max-width: 9rem; white-space: normal; }
#ck-table .sub { max-width: 11rem; margin-left: auto; }
#ck-table td:not(.num) .sub { margin-left: 0; }

/* barrido guiado */
.sweep-setup .row { align-items: flex-end; }
.sw-summary { margin-top: .6rem; font-size: .95rem; color: var(--text-dim); }
.sweep-current { position: relative; padding: 1.4rem; margin-bottom: 1.2rem; border: 2px solid var(--gold-dim); border-radius: var(--radius);
  background: radial-gradient(ellipse at top, rgba(216, 173, 85, .08), transparent 70%), var(--ink-1); }
.sw-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.sw-head .ck-bar { flex: 1; }
.sw-count { font: 700 1rem var(--f-display); color: var(--gold); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.sw-filters { display: flex; flex-wrap: wrap; align-items: stretch; gap: .5rem; margin-bottom: 1rem; }
.sw-arrow { align-self: center; color: var(--gold-dim); font-size: 1.4rem; }
.sw-f { position: relative; display: flex; flex-direction: column; gap: .2rem; min-width: 8.5rem; padding: .7rem 1rem;
  background: var(--ink-3); border: 1px solid var(--rule-strong); border-radius: var(--radius); }
.sw-f span { font-size: .8rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.sw-f b { font: 700 1.6rem/1.15 var(--f-mono); color: var(--text); }
.sw-f.changed { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-glow), 0 0 16px rgba(216, 173, 85, .2); }
.sw-f.changed b { color: var(--gold-bright); }
.sw-f em { position: absolute; top: -.6rem; right: .5rem; padding: 0 .4rem; font: 700 .7rem var(--f-ui); font-style: normal; text-transform: uppercase;
  color: #1b1206; background: var(--gold); border-radius: var(--radius); }
.sw-why { font-size: .95rem; color: var(--text-dim); margin-bottom: .8rem; line-height: 1.6; }
.sw-live { padding: .8rem 1rem; border-radius: var(--radius); font-size: 1.02rem; border: 1px solid var(--rule); }
.sw-live.waiting { color: var(--amber); background: var(--amber-bg); border-color: rgba(243, 181, 79, .35); }
.sw-live.ok { color: var(--profit); background: var(--profit-bg); border-color: rgba(110, 227, 155, .35); }
.sw-profit { margin-top: .7rem; padding: .7rem 1rem; border: 1px solid var(--gold); border-radius: var(--radius); background: rgba(216, 173, 85, .08); }
.sw-pitem { display: inline-flex; align-items: center; gap: .5rem; margin: .3rem 1rem .3rem 0; }
.sw-buttons { margin-top: 1rem; }
.sw-buttons .primary { min-width: 12rem; }
.sw-done { font-size: 1.1rem; color: var(--gold-bright); padding: .5rem 0; }
.sw-list-head { margin-bottom: .6rem; font-size: .9rem; }
.sw-li { display: flex; align-items: center; gap: .8rem; padding: .45rem .7rem; border-bottom: 1px solid rgba(84, 69, 44, .4); cursor: pointer; color: var(--text-dim); }
.sw-li:hover { background: rgba(216, 173, 85, .06); }
.sw-li.current { color: var(--gold-bright); background: rgba(216, 173, 85, .1); font-weight: 600; }
.sw-li.done { color: var(--profit); }
.sw-li.skipped { opacity: .6; }
.sw-mark { width: 1.2rem; text-align: center; }
.sw-li-info { margin-left: auto; font: .85rem var(--f-mono); }
