/* StrikeLine — tema oscuro monocromático con un solo acento dorado */
@font-face {
  font-family: 'Manrope';
  src: url('/fonts/manrope.woff2') format('woff2');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #0e1116;
  --surface: #151a22;
  --surface-2: #1b212b;
  --surface-3: #222935;
  --line: #262d38;
  --line-soft: #1f252f;
  --text: #e7e2d6;
  --text-2: #b0b4bc;
  --muted: #838a95;
  --gold: #d4af37;
  --gold-2: #e6c563;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --gold-line: rgba(212, 175, 55, 0.35);
  --up: #4cc38a;
  --down: #e8696d;
  --warn: #e0a64b;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--gold-2); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.pos { color: var(--up); }
.neg { color: var(--down); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 8px; }

/* ---------- Encabezado ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 12px max(24px, env(safe-area-inset-left));
  background: rgba(14, 17, 22, 0.82);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; letter-spacing: -0.4px; white-space: nowrap; }
.brand img { display: block; }
.brand em { font-style: normal; color: var(--gold); }
.spacer { flex: 1; }
.actions { display: flex; gap: 8px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; min-width: 40px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text-2); cursor: pointer; font-weight: 600; font-size: 14px; transition: border-color .15s, color .15s;
}
.icon-btn:hover { border-color: var(--gold-line); color: var(--text); }
.icon-btn:disabled { opacity: .5; cursor: default; }
.icon-btn svg { width: 18px; height: 18px; }
.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Navegación ---------- */
.nav {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border: 0; border-radius: 10px;
  background: none; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 600; font-size: 14px;
}
.tab svg { width: 18px; height: 18px; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface-3); color: var(--text); }
.tab.active svg { color: var(--gold); }

/* ---------- Contenido ---------- */
main { width: 100%; margin: 0 auto; padding: 24px clamp(16px, 2.5vw, 40px) 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 26px; letter-spacing: -0.6px; font-weight: 800; }
.meta { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.notice { font-size: 13px; color: var(--muted); margin: 0 0 18px; }
.notice summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
.notice summary::-webkit-details-marker { display: none; }
.notice summary svg { width: 14px; height: 14px; }
.notice p { margin: 8px 0 0; max-width: 760px; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.kpi .v { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; margin-top: 2px; }
.kpi .v.gold { color: var(--gold-2); }

/* Filtros */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.chip:hover { color: var(--text); }
.chip.active { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold-2); }
.filter-panel {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
}
.field { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .form input, .form select, textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--text);
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .form input:focus, .form select:focus, textarea:focus { border-color: var(--gold-line); outline: none; }
.switches { display: grid; gap: 8px; }
.switch { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; font-weight: 600; }
.switch input { appearance: none; -webkit-appearance: none; width: 36px; height: 22px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked { background: var(--gold-soft); border-color: var(--gold-line); }
.switch input:checked::after { transform: translateX(14px); background: var(--gold); }

/* Tarjetas de oportunidad */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 14px; transition: border-color .15s;
}
.card:hover { border-color: var(--line); }
.card-head { display: flex; align-items: flex-start; gap: 12px; }
.ticker { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-3); display: grid; place-items: center; font-weight: 800; font-size: 11px; letter-spacing: .3px; color: var(--text); flex: none; }
.card-title { flex: 1; min-width: 0; }
.card-title .sym { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }
.card-title .strat { font-size: 13px; color: var(--muted); font-weight: 600; }
.pill { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.pill.gold { background: var(--gold-soft); color: var(--gold-2); }
.sub { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 8px; background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 600; }
.tag.up { color: var(--up); }
.tag.down { color: var(--down); }
.tag.warn { color: var(--warn); }

.legs { display: grid; gap: 8px; }
.leg { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; background: var(--bg); border: 1px solid var(--line-soft); border-radius: 12px; padding: 10px 12px; }
.leg .act { grid-row: span 2; font-size: 11px; font-weight: 800; letter-spacing: .5px; padding: 4px 8px; border-radius: 6px; border: 1px solid; text-align: center; min-width: 64px; }
.leg .act.sell { color: var(--down); border-color: rgba(232, 105, 109, .35); }
.leg .act.buy { color: var(--up); border-color: rgba(76, 195, 138, .35); }
.leg .main { font-weight: 700; }
.leg .det { font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line-soft); border-radius: 12px; overflow: hidden; }
.stat { background: var(--surface); padding: 10px 12px; }
.stat .k { font-size: 11px; color: var(--muted); font-weight: 600; }
.stat .v { font-weight: 800; font-size: 15px; margin-top: 1px; }

.prob { display: grid; gap: 6px; }
.prob-row { display: grid; grid-template-columns: 64px 1fr 40px; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > div { height: 100%; border-radius: 999px; background: var(--muted); }
.bar.model > div { background: var(--gold); }
.prob-row .num { text-align: right; color: var(--text-2); }

/* Tablas */
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
th { color: var(--muted); font-weight: 700; font-size: 12px; background: var(--surface); }
td { background: var(--surface); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td:first-child, th:first-child { position: sticky; left: 0; z-index: 1; }
.sig-sell { color: var(--gold-2); font-weight: 700; }
.sig-buy { color: var(--up); font-weight: 700; }
.foot { color: var(--muted); font-size: 12px; margin: 12px 2px 0; max-width: 860px; }

/* Formularios */
h2 { font-size: 17px; margin: 0 0 12px; letter-spacing: -0.3px; }
.section { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.form { display: grid; gap: 12px; max-width: 520px; }
.form label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn {
  height: 42px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--text); font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--gold-line); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #17130a; }
.btn.primary:hover { background: var(--gold-2); }
.btn:disabled { opacity: .5; cursor: default; }
.msg { font-size: 13px; min-height: 18px; }
.msg.err { color: var(--down); }
.msg.ok { color: var(--up); }
.empty, .loading { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 56px 16px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

/* Login */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login { width: 100%; max-width: 400px; display: grid; gap: 14px; }
.login-head { text-align: center; margin-bottom: 8px; }
.login-head img { display: block; margin: 0 auto 14px; }
.login-head .brand { justify-content: center; font-size: 28px; }
.login-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.login .card { gap: 14px; padding: 22px; }
.login .btn { width: 100%; height: 46px; }
.login label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login input { width: 100%; height: 46px; padding: 0 14px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: 16px; }
.login input:focus { border-color: var(--gold-line); outline: none; }
.legal { text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- Escritorio: navegación dentro del encabezado ---------- */
@media (min-width: 900px) {
  .top .nav { order: 2; margin-left: 12px; }
  .top .spacer { order: 3; }
  .top .actions { order: 4; }
  .filters-toggle { display: none; }
  .filter-panel.collapsed { display: grid; }
}

/* ---------- Tablet / celular: barra inferior tipo app ---------- */
@media (max-width: 899px) {
  /* sin blur en el encabezado: si no, la barra inferior quedaría atrapada dentro de él */
  .top { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .top { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    border-radius: 0; border: 0; border-top: 1px solid var(--line);
    background: rgba(21, 26, 34, 0.94);
    backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .tab { flex: 1; flex-direction: column; gap: 3px; height: 52px; padding: 0 2px; font-size: 10.5px; border-radius: 12px; }
  .tab svg { width: 22px; height: 22px; }
  .tab.active { background: none; color: var(--gold-2); }
  main { padding: 16px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .v { font-size: 20px; }
  .filter-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-panel .wide { grid-column: 1 / -1; }
  .filter-panel.collapsed { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .page-head h1 { font-size: 22px; }
  .grid { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 14px; gap: 12px; }
  .icon-btn .lbl { display: none; }
  .icon-btn { padding: 0; width: 40px; }
  th, td { padding: 10px 12px; font-size: 13px; }
  .form { max-width: none; }
  .form input, .form select, textarea, .field input, .field select { font-size: 16px; }
}

/* ---------- Gráfica ---------- */
.card { cursor: pointer; }
.card .chart-link { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; color: var(--gold-2); font-weight: 700; font-size: 13px; cursor: pointer; }
.card .chart-link svg { width: 16px; height: 16px; }
dialog#chartDlg {
  width: min(1040px, 96vw); max-height: 94vh; padding: 0; margin: auto;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line); border-radius: 20px; overflow: hidden;
}
dialog#chartDlg::backdrop { background: rgba(5, 7, 10, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dlg-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line-soft); }
.dlg-head .card-title { flex: 1; }
.dlg-body { padding: 14px 16px 18px; overflow-y: auto; max-height: calc(94vh - 70px); display: grid; gap: 10px; }
.seg { display: flex; gap: 2px; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.seg-btn { height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-weight: 700; font-size: 12px; cursor: pointer; }
.seg-btn.active { background: var(--surface-3); color: var(--gold-2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 3px; border-radius: 2px; display: inline-block; }
.dash { width: 14px; height: 0; border-top: 2px dashed; display: inline-block; }
.d-s20 { background: #6f7682; }
.d-s50 { background: #b0b4bc; }
.d-s200 { background: #e7e2d6; }
.d-strike { border-color: var(--gold); }
.d-be { border-color: var(--warn); }
.chart-main { height: 380px; position: relative; border-radius: 12px; overflow: hidden; }
.chart-rsi { height: 120px; border-radius: 12px; overflow: hidden; }
.chart-sub-label { font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: -6px; }
.chart-main .loading { position: absolute; inset: 0; display: grid; place-items: center; padding: 0; border: 0; }
@media (max-width: 560px) {
  dialog#chartDlg { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; border: 0; }
  .dlg-head { padding-top: max(14px, env(safe-area-inset-top)); flex-wrap: wrap; }
  .dlg-head .seg { order: 3; width: 100%; justify-content: stretch; }
  .dlg-head .seg-btn { flex: 1; }
  .dlg-body { max-height: none; height: calc(100dvh - 120px); padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .chart-main { height: 300px; }
}

/* Tendencia por marco de tiempo */
.trend-strip { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.tchip { display: grid; gap: 2px; padding: 8px 10px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line-soft); cursor: pointer; text-align: left; color: var(--text); }
.tchip:hover { border-color: var(--line); }
.tchip.active { border-color: var(--gold-line); }
.tchip .tf { font-size: 11px; font-weight: 800; color: var(--muted); }
.tchip .tr { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 4px; }
.tchip .rs { font-size: 11px; color: var(--muted); font-weight: 600; }
.tchip.up .tr { color: var(--up); }
.tchip.down .tr { color: var(--down); }
.tchip.sideways .tr { color: var(--text-2); }
.tchip.na .tr { color: var(--muted); }
.trend-sum { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-weight: 600; }
.trend-sum strong { color: var(--text); }
@media (max-width: 560px) {
  .trend-strip { gap: 6px; }
  .tchip { padding: 7px 6px; }
  .tchip .tr { font-size: 12px; }
}

/* Tablas compactas en pantallas grandes para que quepan sin barra horizontal */
@media (min-width: 900px) {
  #marketTable th, #marketTable td, #unusualTable th, #unusualTable td, #usersTable th, #usersTable td { padding: 11px 10px; font-size: 13.5px; }
  #marketTable th, #unusualTable th, #usersTable th { font-size: 11.5px; }
}
.foot { max-width: none; }

.mt10 { margin-top: 10px; }
.form .switch { display: flex; color: var(--text-2); font-size: 13px; }
.out-win { color: var(--up); font-weight: 700; }
.out-loss { color: var(--down); font-weight: 700; }
.out-open { color: var(--text-2); }
@media (max-width: 899px) { .tab { font-size: 10px; } .tab svg { width: 20px; height: 20px; } }
tr.clickable { cursor: pointer; }
