/* Copper Status — paleta neutra con tinte marino, bronce COFICAB como acento,
   teal/coral (aptos para daltonismo) solo para el signo, siempre con ▲▼. */
:root {
  --bg: #0E1220; --surface: #161B2E; --raised: #1E2540; --border: #2A3150; --rule: #232A44;
  --text: #E6E8EF; --text-2: #9AA1B5; --text-3: #6B7390;
  --accent: #C8935A; --pos: #3DB7A4; --neg: #F07167; --stale: #E9B949;
  --comex: #D9A35F; --lme: #7FA7E8;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: 'Inter', 'Segoe UI', system-ui, sans-serif; font-feature-settings: 'tnum' 1, 'cv11' 1; font-variant-numeric: tabular-nums; letter-spacing: -0.005em; }
/* Numbers: Inter with tabular figures (column-aligned) */
.num { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: 'tnum' 1, 'lnum' 1; }
.muted { color: var(--text-2); } .dim { color: var(--text-3); }
.sm { font-size: 0.82em; } .xs { font-size: 0.76em; }
h1, h2, p { margin: 0; }

/* Una sola escala: todo en em, la base crece con ancho y alto de la ventana */
.dash { height: 100vh; overflow: hidden; font-size: clamp(11px, calc(0.5vw + 0.75vh), 20px);
        padding: 1em 1.2em; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; gap: 0.85em; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 0.7em; min-width: 0; }
.sec { font-size: 0.88em; font-weight: 600; color: var(--accent); letter-spacing: 0.04em; white-space: nowrap; }
.sec .muted { font-weight: 400; }

/* Encabezado */
.hdr { display: flex; align-items: center; gap: 1.3em; padding: 0.6em 1em; }
.brand { height: 2.7em; width: auto; display: block; flex: none; }
.title { display: flex; flex-direction: column; flex: none; border-left: 1px solid var(--border); padding-left: 1em; }
.title h1 { font-size: 1.4em; font-weight: 600; line-height: 1.15; }
.title span { font-size: 0.82em; }
.pills { display: flex; gap: 0.55em; flex: none; flex-wrap: wrap; }
.pill { display: inline-flex; align-items: center; gap: 0.45em; padding: 0.35em 0.75em; border-radius: 999px;
        border: 1px solid var(--border); font-size: 0.85em; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.pill i { width: 0.6em; height: 0.6em; border-radius: 50%; background: var(--text-3); }
.pill.open { color: var(--neg); } .pill.open i { background: var(--neg); animation: pulse 2s ease-in-out infinite; }   /* LIVE = rojo */
@keyframes pulse { 50% { opacity: 0.35; } }
.fxs { flex: 1; min-width: 0; display: flex; justify-content: flex-end; gap: 0.75em; flex-wrap: wrap; }
.fx { display: flex; align-items: center; gap: 0.6em; padding-left: 0.8em; border-left: 1px solid var(--border); line-height: 1.2; }
.fx-main { display: flex; flex-direction: column; }
.fx .p { font-size: 0.78em; color: var(--text-2); letter-spacing: 0.03em; white-space: nowrap; }
.fx .v { font-size: 1.2em; font-weight: 500; }
.fx-q { margin: 0; display: grid; grid-template-columns: auto auto; column-gap: 0.6em; row-gap: 0.05em; font-size: 0.76em; align-items: baseline; }
.fx-q dt { color: var(--text-3); letter-spacing: 0.05em; text-transform: uppercase; font-size: 0.85em; }
.fx-q dd { margin: 0; text-align: right; color: var(--text-2); white-space: nowrap; }
.upd { flex: none; text-align: right; border-left: 1px solid var(--border); padding-left: 1em; line-height: 1.25; }
.upd .num { font-size: 1em; white-space: nowrap; }
.upd.stale .num, .upd.stale #conn { color: var(--stale); }

/* Columnas */
.cols { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 0.85em; min-height: 0; }
.left { display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 0.85em; min-height: 0; min-width: 0; }

/* Tarjetas de mercado */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85em; }
.mkt { padding: 0.9em 1.1em; display: flex; flex-direction: column; gap: 0.45em; }
.mkt-hd { display: flex; justify-content: space-between; align-items: center; gap: 0.7em; }
.mkt-id { display: flex; align-items: center; gap: 0.7em; min-width: 0; }
.mkt-id h2 { font-size: 0.95em; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.logo-tile { width: 7.6em; height: 2.4em; border-radius: 0.35em; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: none; }
.logo-tile img { height: 100%; width: auto; display: block; }
.hero { display: flex; align-items: baseline; gap: 0.6em; flex-wrap: wrap; }
.big { font-size: 3.6em; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.hero .muted { white-space: nowrap; }
.delta { font-size: 0.95em; }
.delta small { color: var(--text-2); font-size: 1em; }
.avgs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6em; border-top: 1px solid var(--border); padding-top: 0.55em; margin-top: 0.1em; }
.avgs > div { display: flex; flex-direction: column; min-width: 0; }
.lbl { font-size: 0.75em; color: var(--text-2); letter-spacing: 0.03em; }
.med { font-size: 1.4em; }

/* Diferencias */
.dstrip { padding: 0.7em 1.1em; display: flex; align-items: center; gap: 1.2em; }
.dgrid { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85em; }
.d { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6em; border-left: 1px solid var(--border); padding-left: 0.85em; min-width: 0; }
.d .muted { font-size: 0.82em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.d .num { font-size: 1.35em; font-weight: 500; white-space: nowrap; }

/* Gráfica */
.chart { padding: 0.85em 1.1em; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 0.55em; min-height: 0; }
.chart-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 0.85em; flex-wrap: wrap; }
.legend { display: flex; gap: 1.1em; font-size: 0.82em; color: var(--text-2); flex-wrap: wrap; }
.legend span { white-space: nowrap; } .legend b { color: var(--text); font-weight: 600; }
.sw { display: inline-block; width: 1em; height: 0.22em; vertical-align: middle; margin-right: 0.4em; }
.plot { position: relative; min-height: 8em; overflow: hidden; }
/* Tooltip del crosshair */
.tip { position: absolute; z-index: 3; pointer-events: none; background: var(--raised); border: 1px solid var(--border);
       border-radius: 0.5em; padding: 0.5em 0.7em; font-size: 0.82em; line-height: 1.45; box-shadow: 0 6px 18px rgba(0,0,0,.35); min-width: 11em; }
.tip .t { color: var(--text-2); margin-bottom: 0.15em; }
.tip .r { display: flex; justify-content: space-between; gap: 1.2em; }
.tip .r b { font-weight: 600; }


/* Arbitraje */
.arb { padding: 0.85em 1.1em; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; gap: 0.7em; min-height: 0; }
.arb-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 0.6em; flex-wrap: wrap; }
.boxes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.55em; }
.box { background: var(--raised); border-radius: 0.55em; padding: 0.55em 0.65em; display: flex; flex-direction: column; gap: 0.15em; min-width: 0; }
.box .k { font-size: 0.75em; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box .num { font-size: 1.2em; font-weight: 500; white-space: nowrap; }
.tblwrap { min-height: 0; overflow: hidden; }
table { width: 100%; height: 100%; border-collapse: collapse; font-size: 0.9em; }
th { font-weight: 500; color: var(--text-2); text-align: right; padding: 0.3em 0.45em; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { text-align: right; padding: 0.2em 0.45em; border-bottom: 1px solid var(--rule); white-space: nowrap; }
th.l, td.l { text-align: left; }
td.per { color: var(--text-2); }
td.diff { font-weight: 600; }
tr.cur { background: var(--raised); } tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.foot { margin-top: 0; }

.pos { color: var(--pos); } .neg { color: var(--neg); } .nil { color: var(--text-3); }

/* Cintillo de noticias: corre de derecha a izquierda, se pausa con el mouse */
.ticker { display: flex; align-items: center; gap: 1em; padding: 0.5em 1em; overflow: hidden; }
.tk-label { flex: none; display: flex; flex-direction: column; line-height: 1.1; font-size: 0.8em; font-weight: 700;
            letter-spacing: 0.06em; color: var(--accent); border-right: 1px solid var(--border); padding-right: 1em; }
.tk-label small { font-weight: 500; letter-spacing: 0.02em; color: var(--text-3); font-size: 0.85em; }
.tk-viewport { flex: 1; min-width: 0; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 2em, #000 calc(100% - 2em), transparent); }
.tk-track { display: inline-flex; white-space: nowrap; will-change: transform; animation: tk var(--tk-dur, 120s) linear infinite; }
.ticker:hover .tk-track, body.reading .tk-track { animation-play-state: paused; }
.tk-item { display: inline-flex; align-items: baseline; gap: 0.6em; padding: 0 2.2em 0 0; font: inherit; font-size: 0.92em;
           color: var(--text); background: none; border: 0; cursor: pointer; white-space: nowrap; }
.tk-item:hover, .tk-item:focus-visible { color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; outline: none; }
.tk-item time { color: var(--text-3); font-size: 0.85em; }

/* Visor de la nota completa */
.art { padding: 0; border: 0; background: transparent; color: var(--text); max-width: min(52em, calc(100vw - 2em)); width: 100%; }
.art::backdrop { background: rgba(6, 8, 15, 0.72); }
.art-box { background: var(--surface); border: 1px solid var(--border); border-radius: 0.7em; padding: 1.1em 1.4em 1em;
           display: flex; flex-direction: column; gap: 0.5em; max-height: calc(100vh - 3em); }
.art-hd { display: flex; align-items: center; justify-content: space-between; }
.art-hd .tk-label { border-right: 0; padding-right: 0; }
.art-x { font: inherit; font-size: 1.6em; line-height: 1; color: var(--text-2); background: none; border: 0; cursor: pointer; padding: 0 0.2em; }
.art-x:hover, .art-x:focus-visible { color: var(--text); outline: none; }
.art h2 { margin: 0; font-size: 1.35em; font-weight: 600; line-height: 1.25; }
.art-sum { margin: 0.2em 0 0; color: var(--text-2); font-style: italic; }
.art-sum:empty { display: none; }
.art-body { overflow-y: auto; min-height: 0; line-height: 1.55; border-top: 1px solid var(--border); padding-top: 0.6em; padding-right: 0.4em; }
.art-body p { margin: 0 0 0.8em; }
.art-body a, .art-ft a { color: var(--accent); }
.art-body table { width: auto; margin: 0.5em 0 1em; }
.art-body td, .art-body th { text-align: left; white-space: normal; }
.art-ft { border-top: 1px solid var(--border); padding-top: 0.6em; font-size: 0.9em; }
.art-ft a { text-decoration: none; font-weight: 600; } .art-ft a:hover { text-decoration: underline; }
.tk-item::after { content: ''; width: 0.35em; height: 0.35em; border-radius: 50%; background: var(--accent); margin-left: 2.2em; align-self: center; }
.tk-empty { color: var(--text-3); font-size: 0.9em; }
@keyframes tk { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* "Lucecitas": destello al cambiar un valor (teal si sube, coral si baja) */
.flash-up { animation: flashUp 1.2s ease-out; }
.flash-down { animation: flashDown 1.2s ease-out; }
@keyframes flashUp { 0% { background: rgba(61, 183, 164, 0.55); } 100% { background: transparent; } }
@keyframes flashDown { 0% { background: rgba(240, 113, 103, 0.55); } 100% { background: transparent; } }
[data-k], .fx .v, .fx-q dd, .box .num, td { border-radius: 0.2em; }
@media (prefers-reduced-motion: reduce) { .flash-up, .flash-down, .pill.open i { animation: none; } .tk-track { animation-duration: 600s; } }

/* Pantallas angostas o bajas: una columna con scroll */
@media (max-width: 1100px), (max-height: 600px) {
  .dash { height: auto; min-height: 100vh; overflow: visible; font-size: clamp(13px, 1.6vw, 16px); }
  .cols { grid-template-columns: minmax(0, 1fr); }
  .left, .arb { grid-template-rows: auto; }
  .chart { height: auto; } .plot { height: 18em; }
  .hdr { flex-wrap: wrap; }
  .fxs { justify-content: flex-start; flex-basis: 100%; }
  table { height: auto; } td { padding: 0.45em; }
}
/* Celular */
@media (max-width: 700px) {
  .dash { font-size: clamp(13px, 3.6vw, 17px); padding: 1em; }
  .title { border-left: none; padding-left: 0; }
  .upd { border-left: none; padding-left: 0; text-align: left; }
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .big { font-size: 2.8em; }
  .dstrip { flex-direction: column; align-items: stretch; }
  .dgrid { grid-template-columns: minmax(0, 1fr); }
  .d { border-left: none; border-top: 1px solid var(--rule); padding: 0.45em 0 0; }
  .fx { padding-left: 0; border-left: none; }
  .fx-main { width: 7.5em; }
  .fxs { gap: 0.8em 1.4em; }
  .boxes { grid-template-columns: repeat(auto-fit, minmax(7.5em, 1fr)); }
  .c-per, .c-cont, .c-back, td.per, td.cont, td.back { display: none; }
  .plot { height: max(16em, 240px); }
  .legend { flex-direction: column; gap: 0.2em; }
}

/* Auth: login, invitación, admin y menú de usuario */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 1.5em 1em; font-size: 15px; }
.auth-card { width: min(26em, 100%); padding: 2em 2em 1.6em; display: flex; flex-direction: column; gap: 1.1em; }
.auth-brand { display: flex; align-items: center; gap: 1em; }
.auth-brand .brand { height: 2.4em; }
.auth-brand .title h1 { font-size: 1.3em; }
.auth-card h2 { font-size: 1.15em; font-weight: 600; line-height: 1.3; }
.auth-card p { line-height: 1.5; }
.who { background: var(--raised); border-radius: 0.55em; padding: 0.7em 0.9em; display: flex; flex-direction: column; gap: 0.15em; }
.who b { font-weight: 600; }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 0.5em;
       padding: 0.7em 1.1em; border-radius: 0.55em; border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--raised); }
.btn-sm { padding: 0.35em 0.7em; font-size: 0.85em; font-weight: 500; }
.btn-danger { color: var(--neg); }
.btn:disabled { opacity: 0.55; cursor: default; filter: none; }
.btn:focus-visible, .field input:focus-visible, .field select:focus-visible, .umenu-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-block { width: 100%; }
.field { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; }
.field label { font-size: 0.82em; color: var(--text-2); letter-spacing: 0.03em; }
.field input, .field select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
       border-radius: 0.5em; padding: 0.6em 0.75em; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 0.5em; font-size: 0.92em; color: var(--text-2); cursor: pointer; }
.check input { accent-color: var(--accent); width: 1.05em; height: 1.05em; }
.msg { min-height: 1.4em; font-size: 0.9em; line-height: 1.45; }
.msg.err { color: var(--neg); } .msg.ok { color: var(--pos); }
.auth-alt { display: flex; flex-direction: column; gap: 0.7em; border-top: 1px solid var(--border); padding-top: 1em; }
.auth-foot { font-size: 0.8em; }
[hidden] { display: none !important; }

/* Menú de usuario: va en la línea de "Last update" para no quitarle ancho a los FX (encabezado en una línea a 1440 px) */
.upd-top { display: flex; align-items: center; justify-content: flex-end; gap: 0.5em; }
.umenu { position: relative; flex: none; text-align: left; margin-block: -0.3em; }
.umenu-btn { font: inherit; display: flex; align-items: center; justify-content: center; width: 2.3em; height: 2.3em; border-radius: 50%;
             background: var(--raised); color: var(--text); border: 1px solid var(--border); cursor: pointer; font-size: 0.7em; font-weight: 600; letter-spacing: 0.02em; }
.umenu-btn:hover { border-color: var(--accent); }
.umenu-pop { position: absolute; right: 0; top: calc(100% + 0.5em); z-index: 20; min-width: 15em; background: var(--raised);
             border: 1px solid var(--border); border-radius: 0.6em; padding: 0.4em; box-shadow: 0 10px 28px rgba(0,0,0,.45); font-size: 0.92em; }
.umenu-who { padding: 0.5em 0.7em 0.6em; border-bottom: 1px solid var(--border); margin-bottom: 0.3em; display: flex; flex-direction: column; gap: 0.1em; }
.umenu-who b { font-weight: 600; }
.umenu-item { font: inherit; display: block; width: 100%; text-align: left; padding: 0.5em 0.7em; border-radius: 0.4em; color: var(--text);
              background: none; border: 0; cursor: pointer; text-decoration: none; }
.umenu-item:hover, .umenu-item:focus-visible { background: var(--surface); outline: none; }
.umenu-msg { padding: 0.3em 0.7em 0.4em; font-size: 0.9em; }
.umenu-msg:empty { display: none; }

/* Administración */
.admin { font-size: 15px; max-width: 76em; margin: 0 auto; padding: 1em 1.2em 3em; display: flex; flex-direction: column; gap: 1em; }
.admin .hdr { justify-content: space-between; }
.admin .hdr-l { display: flex; align-items: center; gap: 1.3em; }
.admin .hdr-r { display: flex; align-items: center; gap: 0.8em; }
.admin section.panel { padding: 1em 1.2em; display: flex; flex-direction: column; gap: 0.8em; }
.admin .sec-hd { display: flex; justify-content: space-between; align-items: baseline; gap: 1em; flex-wrap: wrap; }
.inv-form { display: grid; grid-template-columns: minmax(10em, 1.2fr) minmax(12em, 1.5fr) minmax(7em, 0.6fr) auto auto; gap: 0.8em; align-items: end; }
.inv-out { display: flex; gap: 0.6em; align-items: center; background: var(--raised); border-radius: 0.55em; padding: 0.6em 0.8em; flex-wrap: wrap; }
.inv-out code { flex: 1; min-width: 12em; word-break: break-all; font-size: 0.85em; color: var(--text); }
.admin table { height: auto; font-size: 0.92em; }
.admin th, .admin td { text-align: left; vertical-align: top; padding: 0.55em 0.6em; white-space: normal; }
.admin td.act { text-align: right; white-space: nowrap; }
.admin td .btn + .btn { margin-left: 0.4em; }
.tag { display: inline-block; padding: 0.1em 0.55em; border-radius: 999px; font-size: 0.8em; font-weight: 600; border: 1px solid var(--border); color: var(--text-2); }
.tag.admin { color: var(--accent); border-color: var(--accent); }
.tag.off { color: var(--neg); border-color: var(--neg); }
.tag.on { color: var(--pos); border-color: var(--pos); }
.pk { display: flex; justify-content: space-between; align-items: center; gap: 0.6em; padding: 0.25em 0; }
.pk + .pk { border-top: 1px solid var(--rule); }
.pk-meta { display: flex; flex-direction: column; }
.empty { color: var(--text-3); padding: 0.6em 0; }
.tblscroll { overflow-x: auto; }
@media (max-width: 900px) { .inv-form { grid-template-columns: minmax(0, 1fr); } .admin .hdr { flex-wrap: wrap; } }
@media (max-width: 700px) { .upd-top { justify-content: flex-start; } .umenu-pop { left: 0; right: auto; } }
