/* ============================================================
   ULTRA BLACK JOURNAL — sistema de diseño
   Paleta heredada de ultrablackpacks.shop: negro puro + oro
   ============================================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  /* hace que los desplegables, el scroll y los controles nativos
     que sí respetan el tema salgan en oscuro y no en blanco */
  color-scheme: dark;

  --gold: #d4af37;
  --gold-lt: #f4d03f;
  --gold-dk: #b8941f;
  --grad-gold: linear-gradient(135deg, #d4af37 0%, #f4d03f 50%, #b8941f 100%);

  --bg: #000000;
  --panel: #0a0a0b;
  --panel-2: #101012;
  --panel-3: #17171a;
  --line: rgba(212, 175, 55, 0.13);
  --line-soft: rgba(255, 255, 255, 0.06);

  --text: #f5f5f7;
  --muted: #8a8a92;
  --faint: #55555e;

  --win: #2ddf9e;
  --loss: #ff5a66;
  --info: #6aa9ff;

  --r: 14px;
  --r-sm: 9px;
  --sidebar-w: 236px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* rejilla dorada de fondo — firma visual de Ultra Black */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(212, 175, 55, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(212, 175, 55, 0.035) 1px, transparent 1px);
  background-size: 64px 64px;
  z-index: 0;
  pointer-events: none;
}
body::after {
  content: '';
  position: fixed;
  top: -20%; left: 50%;
  width: 900px; height: 520px;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(212, 175, 55, 0.09), transparent 68%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}

::selection { background: rgba(212, 175, 55, 0.3); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #060607; }
::-webkit-scrollbar-thumb { background: #24242a; border-radius: 6px; border: 2px solid #060607; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dk); }

/* ============================================================
   LAYOUT
   ============================================================ */

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: rgba(6, 6, 7, 0.92);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--line);
}
.brand-kicker {
  font-size: 9px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--gold-dk); font-weight: 700; margin-bottom: 3px;
}
.brand-name {
  font-size: 17px; font-weight: 800; letter-spacing: -0.02em;
  background: var(--grad-gold);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }

.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--muted);
  font: inherit; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-align: left;
  transition: background .16s, color .16s;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; }
.nav-item:hover { background: rgba(212, 175, 55, 0.07); color: var(--text); }
.nav-item.active {
  background: rgba(212, 175, 55, 0.11);
  color: var(--gold-lt);
  box-shadow: inset 2px 0 0 var(--gold);
}
.nav-item .chev { margin-left: auto; width: 13px; height: 13px; transition: transform .2s var(--ease); }
.nav-group.open > .nav-item .chev { transform: rotate(90deg); }

.subnav { max-height: 0; overflow: hidden; transition: max-height .28s var(--ease); }
.nav-group.open .subnav { max-height: 260px; }
.subnav button {
  width: 100%;
  display: flex; align-items: center; gap: 9px;
  padding: 6px 11px 6px 39px;
  background: none; border: 0; border-radius: var(--r-sm);
  color: var(--faint); font: inherit; font-size: 12.5px;
  cursor: pointer; text-align: left;
  transition: color .15s;
}
.subnav button::before {
  content: ''; width: 4px; height: 4px; border-radius: 50%;
  background: currentColor; opacity: .55; flex: 0 0 4px;
}
.subnav button:hover { color: var(--text); }
.subnav button.active { color: var(--gold); font-weight: 600; }

.sidebar-foot { padding: 10px; border-top: 1px solid var(--line); }
.sidebar-foot .nav-item { font-size: 12.5px; }
.sidebar-ver {
  text-align: center; font-family: var(--mono);
  font-size: 9.5px; color: #2e2e34; padding: 6px 0 10px;
}

.main { flex: 1; min-width: 0; padding: 24px 28px 70px; }

.topbar {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.topbar h1 {
  font-size: 25px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.15;
}
.topbar p { color: var(--muted); font-size: 13px; margin-top: 3px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ============================================================
   PRIMITIVAS
   ============================================================ */

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 16px 18px;
  position: relative;
}
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { font-size: 13.5px; font-weight: 700; letter-spacing: -0.01em; }
.card-h .sub { font-size: 11.5px; color: var(--faint); }
.card-h .spacer { margin-left: auto; }

.label {
  font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--faint); font-weight: 700;
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  background: var(--panel-3); color: var(--text);
  border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
}
.btn:hover { background: #1f1f24; border-color: var(--line); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; }
.btn-gold {
  background: var(--grad-gold); color: #12100a; border-color: transparent;
  box-shadow: 0 3px 16px rgba(212, 175, 55, 0.22);
}
.btn-gold:hover { background: var(--grad-gold); filter: brightness(1.08); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--loss); border-color: rgba(255, 90, 102, 0.28); }
.btn-danger:hover { background: rgba(255, 90, 102, 0.1); }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 11.5px; }

.pills { display: inline-flex; background: #0e0e10; border: 1px solid var(--line-soft); border-radius: 10px; padding: 3px; gap: 2px; }
.pills button {
  padding: 6px 13px; background: none; border: 0; border-radius: 7px;
  color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .15s, color .15s; white-space: nowrap;
}
.pills button:hover { color: var(--text); }
.pills button.active { background: rgba(212, 175, 55, 0.16); color: var(--gold-lt); }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%;
  padding: 9px 11px;
  background: #08080a;
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  color: var(--text);
  font: inherit; font-size: 13px;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #3a3a42; font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: rgba(212, 175, 55, 0.45);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.08);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.55; }
select { appearance: none; cursor: pointer; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
input[type=date], input[type=time] { font-family: var(--mono); }
input[type=date]::-webkit-calendar-picker-indicator,
input[type=time]::-webkit-calendar-picker-indicator { filter: invert(.6) sepia(1) saturate(3) hue-rotate(5deg); cursor: pointer; }

/* ---------- selector de fecha propio ----------
   El calendario nativo de Chrome vive en su shadow DOM y no admite CSS,
   así que los campos de fecha son inputs de texto con este picker encima. */

.dp-in {
  font-family: var(--mono);
  padding-right: 34px !important;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8941f' stroke-width='1.8'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3Cline x1='8' y1='3' x2='8' y2='7'/%3E%3Cline x1='16' y1='3' x2='16' y2='7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 15px;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.dp-in:hover { border-color: rgba(212, 175, 55, 0.32); }
.dp-in.open {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.12);
}

.dp {
  position: fixed; z-index: 150; width: 274px;
  background: linear-gradient(180deg, #16161a, #0b0b0d);
  border: 1px solid rgba(212, 175, 55, 0.34);
  border-radius: 15px; padding: 13px;
  box-shadow: 0 22px 60px rgba(0, 0, 0, .8), 0 0 34px rgba(212, 175, 55, .07);
  animation: dpIn .17s var(--ease);
}
@keyframes dpIn { from { opacity: 0; transform: translateY(-6px) scale(.97); } }

.dp-top { display: flex; align-items: center; gap: 4px; margin-bottom: 11px; }
.dp-title {
  flex: 1; text-align: center;
  font-size: 13px; font-weight: 700; letter-spacing: -0.01em;
  background: var(--grad-gold);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-transform: capitalize;
}
.dp-nav {
  width: 26px; height: 26px; flex: 0 0 26px;
  display: grid; place-items: center;
  background: rgba(212, 175, 55, 0.07);
  border: 1px solid var(--line-soft); border-radius: 8px;
  color: var(--gold-dk); cursor: pointer;
  font: inherit; font-size: 13px; line-height: 1;
  transition: all .15s;
}
.dp-nav:hover { background: rgba(212, 175, 55, 0.18); color: var(--gold-lt); border-color: var(--gold-dk); }

.dp-dow { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.dp-dow span {
  text-align: center; font-size: 9px; font-weight: 700;
  letter-spacing: .1em; color: var(--faint); padding-bottom: 4px;
}
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.dp-d {
  position: relative; aspect-ratio: 1;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 8px;
  color: var(--text); font: inherit; font-size: 12.5px; font-weight: 500;
  font-family: var(--mono); cursor: pointer;
  transition: background .13s, color .13s, transform .1s;
}
.dp-d:hover { background: rgba(212, 175, 55, 0.14); color: var(--gold-lt); }
.dp-d:active { transform: scale(.92); }
.dp-d.out { color: #34343c; }
.dp-d.out:hover { color: var(--muted); }
.dp-d.wknd { color: var(--muted); }
.dp-d.today { box-shadow: inset 0 0 0 1px var(--gold-dk); color: var(--gold-lt); }
.dp-d.sel {
  background: var(--grad-gold); color: #100e08; font-weight: 700;
  box-shadow: 0 3px 14px rgba(212, 175, 55, .38);
}
.dp-d.sel:hover { color: #100e08; }
/* punto de color: días con operaciones registradas */
.dp-d i {
  position: absolute; bottom: 3.5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%;
}
.dp-d.sel i { display: none; }

.dp-foot {
  display: flex; gap: 7px; margin-top: 11px;
  padding-top: 10px; border-top: 1px solid var(--line);
}
.dp-foot button {
  flex: 1; padding: 6px 0;
  background: rgba(212, 175, 55, 0.07);
  border: 1px solid var(--line-soft); border-radius: 8px;
  color: var(--muted); font: inherit; font-size: 11.5px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.dp-foot button:hover { background: rgba(212, 175, 55, 0.16); color: var(--gold-lt); border-color: var(--gold-dk); }
.dp-legend {
  display: flex; justify-content: center; gap: 11px;
  margin-top: 9px; font-size: 9.5px; color: var(--faint);
}
.dp-legend span { display: inline-flex; align-items: center; gap: 4px; }
.dp-legend i { width: 4px; height: 4px; border-radius: 50%; display: block; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 11px; background: #0e0e10;
  border: 1px solid var(--line-soft); border-radius: 999px;
  color: var(--muted); font-size: 11.5px; font-weight: 500; cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--line); color: var(--text); }
.chip.on { background: rgba(212, 175, 55, 0.15); border-color: rgba(212, 175, 55, 0.4); color: var(--gold-lt); }
.chip.on-good { background: rgba(45, 223, 158, 0.13); border-color: rgba(45, 223, 158, 0.35); color: var(--win); }

.seg { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.seg button {
  padding: 8px 15px; background: #0c0c0e;
  border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.seg button:hover { color: var(--text); border-color: var(--line); }
.seg button.active { background: rgba(212, 175, 55, 0.14); border-color: var(--gold-dk); color: var(--gold-lt); }
.seg button.active[data-v=short], .seg button.active[data-v=no] { background: rgba(255, 90, 102, 0.13); border-color: rgba(255, 90, 102, 0.4); color: var(--loss); }
.seg button.active[data-v=long], .seg button.active[data-v=yes] { background: rgba(45, 223, 158, 0.12); border-color: rgba(45, 223, 158, 0.38); color: var(--win); }

.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.g-auto { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
/* proporciones del panel — en clases, no en línea, para que el móvil pueda anularlas */
.g-wide { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.g-cal { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.g-half { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.pos { color: var(--win); }
.neg { color: var(--loss); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ============================================================
   KPI
   ============================================================ */

.kpi {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 16px;
  overflow: hidden; position: relative;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 175, 55, 0.5), transparent);
}
.kpi-l { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.kpi-v {
  font-family: var(--mono); font-size: 23px; font-weight: 700;
  letter-spacing: -0.03em; margin-top: 7px; line-height: 1;
}
.kpi-s { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* ============================================================
   TABLAS
   ============================================================ */

.tw { overflow-x: auto; margin: 0 -18px -16px; padding: 0 2px; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
thead th {
  text-align: right; padding: 9px 12px;
  font-size: 9.5px; letter-spacing: 0.11em; text-transform: uppercase;
  color: var(--faint); font-weight: 700; white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: #08080a; position: sticky; top: 0;
}
thead th:first-child, tbody td:first-child { text-align: left; padding-left: 18px; }
thead th:last-child, tbody td:last-child { padding-right: 18px; }
tbody td { text-align: right; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(212, 175, 55, 0.045); }
tbody tr:last-child td { border-bottom: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--gold); }

.tag {
  display: inline-block; padding: 2px 7px; border-radius: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .03em;
  background: #1a1a1e; color: var(--muted);
}
.tag-long { background: rgba(45, 223, 158, 0.13); color: var(--win); }
.tag-short { background: rgba(255, 90, 102, 0.13); color: var(--loss); }
.tag-gold { background: rgba(212, 175, 55, 0.15); color: var(--gold-lt); }

.empty {
  text-align: center; padding: 44px 20px;
  color: var(--faint); font-size: 13px;
}
.empty strong { display: block; color: var(--muted); font-size: 14px; margin-bottom: 6px; font-weight: 600; }

/* ============================================================
   CALENDARIO
   ============================================================ */

.cal-head { display: grid; grid-template-columns: repeat(7, 1fr) 0.85fr; gap: 6px; margin-bottom: 6px; }
.cal-head div { text-align: center; font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); font-weight: 700; padding-bottom: 4px; }
.cal-head div:last-child { color: var(--gold-dk); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr) 0.85fr; gap: 6px; }
.cal-cell {
  /* sin esto, el contenido ("-$351") impide que la celda encoja y la
     rejilla desborda en pantallas estrechas */
  min-width: 0; overflow: hidden;
  min-height: 68px; border-radius: 10px;
  border: 1px solid var(--line-soft); background: #08080a;
  padding: 7px 8px; position: relative;
  display: flex; flex-direction: column;
}
.cal-cell.void { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(212, 175, 55, .3); }
.cal-cell .d { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.cal-cell.win { background: rgba(45, 223, 158, 0.07); border-color: rgba(45, 223, 158, 0.22); }
.cal-cell.loss { background: rgba(255, 90, 102, 0.07); border-color: rgba(255, 90, 102, 0.22); }
.cal-cell .p { font-family: var(--mono); font-size: 12.5px; font-weight: 700; margin-top: auto; }
.cal-cell .n { font-size: 9.5px; color: var(--faint); }
.cal-week { background: rgba(212, 175, 55, 0.05); border-color: rgba(212, 175, 55, 0.16); }

.year-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 12px; }
.ym { border: 1px solid var(--line-soft); border-radius: 10px; padding: 10px; background: #08080a; }
.ym-t { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 7px; }
.ym-t b { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.ym-t span { font-family: var(--mono); font-size: 11.5px; font-weight: 700; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2.5px; }
.heat i { aspect-ratio: 1; border-radius: 2.5px; background: #131317; display: block; }

/* ============================================================
   BACKTESTING
   ============================================================ */

.bt-list { display: grid; gap: 10px; }
.bt-card {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: var(--r);
  border: 1px solid var(--line-soft); background: #08080a;
  cursor: pointer; transition: all .16s;
}
.bt-card:hover { border-color: var(--line); background: var(--panel-2); transform: translateX(2px); }
.bt-card.active { border-color: var(--gold-dk); background: rgba(212, 175, 55, 0.06); }
.bt-card .bt-n { font-weight: 700; font-size: 14px; }
.bt-card .bt-m { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.bt-card .bt-r { margin-left: auto; text-align: right; }
.bt-card .bt-r b { font-family: var(--mono); font-size: 15px; display: block; }

/* ============================================================
   PANTALLA DE ACCESO
   ============================================================ */

.auth {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center;
  padding: 26px 18px; overflow-y: auto;
  background: radial-gradient(ellipse at 50% -10%, rgba(212, 175, 55, 0.11), transparent 62%), #000;
}
.auth.off { display: none; }

.auth-card {
  width: 100%; max-width: 396px;
  background: linear-gradient(180deg, #131316, #08080a);
  border: 1px solid var(--line);
  border-radius: 19px; padding: 28px 26px 22px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .8);
  animation: dpIn .3s var(--ease);
}
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .brand-name { font-size: 23px; }

.auth-tabs { width: 100%; margin-bottom: 20px; }
.auth-tabs button { flex: 1; }

#auth-form { display: grid; gap: 13px; }
#auth-form .field > span { font-size: 11.5px; }
.auth-go { width: 100%; justify-content: center; padding: 11px; font-size: 13.5px; margin-top: 4px; }

.auth-err {
  display: none;
  padding: 9px 12px; border-radius: 9px;
  background: rgba(255, 90, 102, 0.1);
  border: 1px solid rgba(255, 90, 102, 0.3);
  color: var(--loss); font-size: 12px; line-height: 1.5;
}
.auth-err.on { display: block; }
.auth-err.ok { background: rgba(45, 223, 158, .1); border-color: rgba(45, 223, 158, .3); color: var(--win); }

.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 2px; }
.auth-links button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--faint); font: inherit; font-size: 11.5px;
  text-decoration: underline; text-underline-offset: 3px;
}
.auth-links button:hover { color: var(--gold); }

/* campo de contraseña con botón de ver/ocultar */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 42px !important; }
.pw-eye {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 31px; height: 31px;
  display: grid; place-items: center;
  background: none; border: 0; border-radius: 7px;
  color: var(--faint); cursor: pointer;
  transition: color .15s, background .15s;
}
.pw-eye:hover { color: var(--gold); background: rgba(212, 175, 55, 0.1); }
.pw-eye:focus-visible { outline: 2px solid rgba(212, 175, 55, .5); outline-offset: 1px; }
.pw-eye.on { color: var(--gold-lt); }
.pw-eye svg { width: 16px; height: 16px; display: block; }
.pw-eye .ic-off { display: none; }
.pw-eye.on .ic-on { display: none; }
.pw-eye.on .ic-off { display: block; }

.pw-meter { display: flex; gap: 4px; margin-top: 6px; }
.pw-meter i { flex: 1; height: 3px; border-radius: 2px; background: #1c1c21; transition: background .2s; }
.pw-meter.s1 i:nth-child(-n+1) { background: var(--loss); }
.pw-meter.s2 i:nth-child(-n+2) { background: #f2bc55; }
.pw-meter.s3 i:nth-child(-n+3) { background: #9fd67a; }
.pw-meter.s4 i { background: var(--win); }
.pw-txt { font-size: 10.5px; display: block; margin-top: 3px; }

.auth-warn {
  margin-top: 18px; padding: 11px 13px;
  border-radius: 10px; border: 1px dashed rgba(242, 188, 85, 0.34);
  background: rgba(242, 188, 85, 0.05);
  font-size: 11px; color: var(--muted); line-height: 1.6;
}
.auth-warn b { color: var(--amber, #f2bc55); }

.mail-hint { display: none; font-size: 11px; margin-top: 4px; }
.mail-hint.on { display: block; color: var(--amber, #f2bc55); }
.mail-hint.bad { display: block; color: var(--loss); }
.mail-hint button {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--gold-lt); font: inherit; font-size: 11px; font-weight: 700;
  text-decoration: underline; text-underline-offset: 2px;
}

/* pantalla de confirmación de correo */
.vf-icon {
  width: 52px; height: 52px; margin: 4px auto 14px;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(212, 175, 55, .1); border: 1px solid rgba(212, 175, 55, .3);
  font-size: 23px; color: var(--gold-lt);
}
.vf-title { text-align: center; font-size: 17px; font-weight: 700; }
.vf-sub { text-align: center; font-size: 12.5px; color: var(--muted); margin: 6px 0 18px; line-height: 1.55; }
.vf-sub b { color: var(--text); }
.vf-code {
  width: 100%; text-align: center;
  font-family: var(--mono); font-size: 27px !important; font-weight: 700;
  letter-spacing: .34em; text-indent: .34em;
  padding: 13px 11px !important;
}
.vf-sim {
  margin-top: 16px; padding: 11px 13px; border-radius: 10px;
  border: 1px dashed rgba(106, 169, 255, .3); background: rgba(106, 169, 255, .05);
  font-size: 11px; color: var(--muted); line-height: 1.6; text-align: center;
}
.vf-sim b { color: var(--info); }
.vf-num {
  display: block; margin: 6px 0;
  font-family: var(--mono); font-size: 21px; font-weight: 700;
  letter-spacing: .2em; color: var(--gold-lt);
}

.auth-accounts { margin-top: 14px; }
.auth-accounts .label { display: block; margin-bottom: 7px; }
.auth-acc {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 7px 10px; margin-bottom: 5px;
  background: #08080a; border: 1px solid var(--line-soft);
  border-radius: 9px; color: var(--muted);
  font: inherit; font-size: 12px; cursor: pointer; text-align: left;
  transition: all .15s;
}
.auth-acc:hover { border-color: var(--line); color: var(--text); }
.auth-acc b { color: var(--text); }
.auth-acc span { margin-left: auto; font-size: 10.5px; color: var(--faint); }

[data-only] { display: none; }
.auth.up [data-only="up"] { display: block; }
.auth.up .field[data-only="up"] { display: flex; }
.auth.up .pw-meter[data-only="up"] { display: flex; }

.sidebar-user {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 11px 4px; font-size: 11.5px; color: var(--faint);
  border-top: 1px solid var(--line-soft); margin-top: 6px;
}
.sidebar-user b { color: var(--muted); font-weight: 600; }

/* ============================================================
   COMUNIDAD — perfil, niveles, insignias, clasificación
   ============================================================ */

.notice {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 15px; border-radius: 11px;
  background: rgba(212, 175, 55, 0.06);
  border: 1px solid rgba(212, 175, 55, 0.22);
  font-size: 12.5px; color: var(--muted); line-height: 1.55;
}
.notice b { color: var(--gold-lt); font-weight: 700; }
.notice::before { content: '!'; flex: 0 0 17px; height: 17px; margin-top: 1px; display: grid; place-items: center; border-radius: 50%; background: var(--gold-dk); color: #100e08; font-size: 11px; font-weight: 800; }

.avatar {
  display: grid; place-items: center;
  border-radius: 50%; flex: 0 0 auto;
  background: linear-gradient(145deg, #1d1d21, #0d0d0f);
  border: 2px solid var(--gold-dk);
  font-family: var(--mono); font-weight: 700; color: var(--gold-lt);
  box-shadow: 0 0 22px rgba(212, 175, 55, 0.14);
}
.avatar-lg { width: 82px; height: 82px; font-size: 27px; }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; border-width: 1px; box-shadow: none; }

.lvl-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2.5px 9px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
  border: 1px solid currentColor; background: rgba(255, 255, 255, 0.03);
}
.lvl-chip b { font-family: var(--mono); }

.lvl-bar { height: 9px; border-radius: 5px; background: #131317; overflow: hidden; margin-top: 9px; }
.lvl-fill { height: 100%; border-radius: 5px; background: var(--grad-gold); box-shadow: 0 0 14px rgba(212, 175, 55, .4); transition: width .6s var(--ease); }

.xp-row { display: flex; justify-content: space-between; font-size: 12px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.xp-row:last-child { border-bottom: 0; }
.xp-row span { color: var(--muted); }
.xp-row b { font-family: var(--mono); color: var(--gold-lt); }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 10px; }
.badge {
  padding: 12px; border-radius: 12px; text-align: center;
  border: 1px solid var(--line-soft); background: #08080a;
  transition: transform .16s var(--ease), border-color .16s;
}
.badge.on { border-color: rgba(212, 175, 55, 0.42); background: rgba(212, 175, 55, 0.06); }
.badge.on:hover { transform: translateY(-2px); }
.badge .bi { font-size: 21px; line-height: 1; filter: grayscale(1) opacity(.28); }
.badge.on .bi { filter: none; }
.badge .bt { font-size: 11.5px; font-weight: 700; margin-top: 7px; color: var(--faint); }
.badge.on .bt { color: var(--gold-lt); }
.badge .bd { font-size: 10px; color: #3f3f47; margin-top: 3px; line-height: 1.4; }
.badge.on .bd { color: var(--muted); }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.pod {
  border-radius: 14px; padding: 16px 12px; text-align: center;
  border: 1px solid var(--line-soft); background: #08080a;
  position: relative; overflow: hidden;
}
.pod::after { content: ''; position: absolute; inset: 0 0 auto 0; height: 2px; }
.pod-1 { border-color: rgba(212, 175, 55, .5); background: linear-gradient(180deg, rgba(212, 175, 55, .1), #08080a); padding-top: 26px; }
.pod-1::after { background: var(--grad-gold); }
.pod-2 { border-color: rgba(190, 190, 200, .3); }
.pod-2::after { background: linear-gradient(90deg, #6c6c78, #c3c3cf, #6c6c78); }
.pod-3 { border-color: rgba(190, 130, 80, .3); }
.pod-3::after { background: linear-gradient(90deg, #7a4a24, #c98b52, #7a4a24); }
.pod .medal { font-size: 21px; }
.pod .pod-a { font-weight: 700; font-size: 13.5px; margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pod-p { font-family: var(--mono); font-size: 21px; font-weight: 700; margin-top: 5px; }
.pod .pod-s { font-size: 10.5px; color: var(--faint); margin-top: 3px; }
.pod .avatar { margin: 0 auto; }

tr.me { background: rgba(212, 175, 55, 0.09) !important; box-shadow: inset 2px 0 0 var(--gold); }
tr.me td { color: var(--text); }
.pos-n { font-family: var(--mono); font-weight: 700; color: var(--faint); }
.pos-n.top { color: var(--gold-lt); }
.ver-dot {
  display: inline-grid; place-items: center;
  width: 15px; height: 15px; border-radius: 50%;
  background: rgba(45, 223, 158, .16); color: var(--win);
  font-size: 9px; font-weight: 800; margin-left: 5px; vertical-align: middle;
}
.rk-user { display: flex; align-items: center; gap: 9px; }
.flag { color: var(--amber, #f2bc55); font-size: 10.5px; cursor: help; }

@media (max-width: 700px) {
  .podium { grid-template-columns: 1fr; }
  .pod-1 { padding-top: 16px; order: -1; }
}

/* ============================================================
   TEMPORADA, RETOS, RECURSOS Y PLANES
   ============================================================ */

/* --- temporada con cuenta atrás --- */
.season {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 15px 19px; border-radius: var(--r);
  border: 1px solid rgba(212, 175, 55, 0.3);
  background: linear-gradient(120deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.02) 55%, transparent);
  position: relative; overflow: hidden;
}
.season::before {
  content: ''; position: absolute; inset: -60% auto auto -10%;
  width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, .16), transparent 68%);
  pointer-events: none;
}
.season-t { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-dk); font-weight: 700; }
.season-n { font-size: 18px; font-weight: 800; letter-spacing: -.02em; margin-top: 2px; text-transform: capitalize; }
.season-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.clock { display: flex; gap: 7px; margin-left: auto; }
.clock div {
  min-width: 50px; text-align: center; padding: 7px 8px;
  background: #08080a; border: 1px solid var(--line); border-radius: 10px;
}
.clock b { display: block; font-family: var(--mono); font-size: 18px; font-weight: 700; color: var(--gold-lt); line-height: 1; }
.clock span { font-size: 8.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); }

.prizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.prize {
  padding: 11px 13px; border-radius: 11px; background: #08080a;
  border: 1px solid var(--line-soft); display: flex; align-items: center; gap: 10px;
}
.prize .pm { font-size: 17px; }
.prize .pn { font-size: 9.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); font-weight: 700; }
.prize .pv { font-size: 13px; font-weight: 700; color: var(--gold-lt); }
.prize.p1 { border-color: rgba(212, 175, 55, .38); background: rgba(212, 175, 55, .06); }

/* --- retos --- */
.reto {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; border-radius: 12px;
  border: 1px solid var(--line-soft); background: #08080a;
  transition: border-color .18s, background .18s;
}
.reto.done { border-color: rgba(45, 223, 158, .38); background: rgba(45, 223, 158, .05); }
.reto .ri { font-size: 20px; width: 26px; text-align: center; flex: 0 0 26px; }
.reto.done .ri { filter: none; }
.reto:not(.done) .ri { filter: grayscale(1) opacity(.45); }
.reto .rb { flex: 1; min-width: 0; }
.reto .rt { font-size: 13.5px; font-weight: 700; }
.reto .rd { font-size: 11.5px; color: var(--muted); margin-bottom: 7px; }
.reto .rx { font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--gold-lt); white-space: nowrap; }
.reto.done .rx { color: var(--win); }
.rp-bar { height: 6px; border-radius: 4px; background: #131317; overflow: hidden; }
.rp-fill { height: 100%; border-radius: 4px; background: var(--grad-gold); transition: width .7s var(--ease); }
.reto.done .rp-fill { background: linear-gradient(90deg, #1c8f66, #2ddf9e); }
.rp-n { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 4px; display: block; }

/* --- recursos --- */
.dato-card {
  border-color: rgba(212, 175, 55, .3);
  background: linear-gradient(135deg, rgba(212, 175, 55, .08), var(--panel) 60%);
}
.dato-k { font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-dk); font-weight: 700; }
.dato-t { font-size: 15px; line-height: 1.65; margin-top: 9px; color: var(--text); }

.libro {
  padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line-soft); background: #08080a;
  transition: transform .18s var(--ease), border-color .18s;
  display: flex; flex-direction: column; gap: 5px;
}
.libro:hover { transform: translateY(-2px); border-color: rgba(212, 175, 55, .3); }
.libro .lt { font-size: 14px; font-weight: 700; line-height: 1.35; }
.libro .la { font-size: 11.5px; color: var(--gold-dk); font-weight: 600; }
.libro .ld { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 3px; }
.libro .lm { display: flex; gap: 6px; margin-top: auto; padding-top: 8px; flex-wrap: wrap; }

.glos { border-bottom: 1px solid var(--line-soft); padding: 13px 0; }
.glos:last-child { border-bottom: 0; }
.glos dt { font-size: 13.5px; font-weight: 700; color: var(--gold-lt); margin-bottom: 4px; }
.glos dd { font-size: 12.5px; color: var(--muted); line-height: 1.65; }

/* --- planes --- */
.plan {
  border-radius: 16px; padding: 20px 18px;
  border: 1px solid var(--line-soft); background: linear-gradient(180deg, var(--panel-2), var(--panel));
  display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.plan.destacado { border-color: rgba(212, 175, 55, .48); box-shadow: 0 0 34px rgba(212, 175, 55, .09); }
.plan.destacado::before {
  content: 'RECOMENDADO'; position: absolute; top: 12px; right: -30px;
  background: var(--grad-gold); color: #100e08;
  font-size: 8.5px; font-weight: 800; letter-spacing: .12em;
  padding: 3px 34px; transform: rotate(38deg);
}
.plan.actual { border-color: var(--win); }
.plan-n { font-size: 17px; font-weight: 800; }
.plan-l { font-size: 11.5px; color: var(--muted); margin-top: 2px; min-height: 30px; }
.plan-p { font-family: var(--mono); font-size: 31px; font-weight: 700; margin: 12px 0 2px; }
.plan-p small { font-size: 12px; color: var(--faint); font-weight: 500; font-family: 'Inter', sans-serif; }
.plan ul { list-style: none; margin: 14px 0 18px; display: grid; gap: 8px; }
.plan li { font-size: 12.5px; color: var(--muted); display: flex; gap: 8px; line-height: 1.45; }
.plan li::before { content: '✓'; color: var(--win); font-weight: 800; flex: 0 0 auto; }
.plan .btn { width: 100%; justify-content: center; margin-top: auto; }
.plan-badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 9.5px; font-weight: 800; letter-spacing: .1em;
  background: rgba(45, 223, 158, .16); color: var(--win);
}

.admin-box {
  border: 1px dashed rgba(106, 169, 255, .32);
  background: rgba(106, 169, 255, .04);
  border-radius: 13px; padding: 16px 18px;
}
.codigo-out {
  font-family: var(--mono); font-size: 17px; font-weight: 700;
  letter-spacing: .06em; color: var(--gold-lt);
  background: #08080a; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px; text-align: center;
  word-break: break-all; user-select: all;
}

.locked {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  padding: 34px 22px; text-align: center;
  border: 1px dashed rgba(212, 175, 55, .28); border-radius: 13px;
  background: rgba(212, 175, 55, .03);
}
.locked .lk { font-size: 25px; }
.locked b { font-size: 14px; }
.locked p { font-size: 12.5px; color: var(--muted); max-width: 380px; line-height: 1.6; }

@media (max-width: 820px) {
  .prizes { grid-template-columns: 1fr; }
  .clock { margin-left: 0; width: 100%; }
}

/* ============================================================
   MODAL
   ============================================================ */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0, 0, 0, 0.78); backdrop-filter: blur(5px);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
}
.overlay.on { display: flex; }
.modal {
  width: 100%; max-width: 560px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 18px; padding: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
  animation: pop .22s var(--ease);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.modal .modal-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 18px; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }

/* toast */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--panel-3); border: 1px solid var(--line);
  border-radius: 11px; padding: 11px 18px;
  font-size: 13px; font-weight: 600; z-index: 200;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  opacity: 0; transition: all .3s var(--ease); pointer-events: none;
}
.toast.on { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.ok { border-color: rgba(45, 223, 158, .4); color: var(--win); }
.toast.err { border-color: rgba(255, 90, 102, .4); color: var(--loss); }

/* privacidad */
body.priv .amt { filter: blur(7px); user-select: none; }

/* utilidades de vista */
.view { display: none; animation: fade .25s var(--ease); }
.view.on { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }

.stack { display: grid; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sec-t { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-dk); font-weight: 700; margin: 4px 0 -2px; }

/* barra de progreso horizontal para desgloses */
.bar-row { display: grid; grid-template-columns: 108px 1fr 84px; gap: 11px; align-items: center; padding: 6px 0; }
.bar-row .bn { font-size: 12px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 7px; background: #131317; border-radius: 4px; overflow: hidden; position: relative; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .5s var(--ease); }
.bar-row .bv { font-family: var(--mono); font-size: 12px; text-align: right; font-weight: 600; }

svg.chart { display: block; width: 100%; height: auto; overflow: visible; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

.sb-toggle { display: none; }

@media (max-width: 1180px) {
  .g-6 { grid-template-columns: repeat(3, 1fr); }
  .g-5 { grid-template-columns: repeat(3, 1fr); }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1040px) {
  .g-wide, .g-cal { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%); transition: transform .28s var(--ease);
  }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0, 0, 0, .9); }
  .main { padding: 18px 15px 60px; }
  .sb-toggle { display: inline-flex; }
  .g-3, .g-2, .g-half, .g-wide, .g-cal { grid-template-columns: minmax(0, 1fr); }
  .cal-head, .cal { grid-template-columns: repeat(7, 1fr); gap: 4px; }
  .cal-head div:last-child, .cal-cell.cal-week { display: none; }
  .cal-cell { min-height: 54px; padding: 5px 4px; }
  .cal-cell .p { font-size: 10px; }
  .cal-cell .n { font-size: 8.5px; }
  .topbar h1 { font-size: 21px; }
}
@media (max-width: 560px) {
  .g-4, .g-5, .g-6, .g-auto { grid-template-columns: repeat(2, 1fr); }
  .kpi-v { font-size: 19px; }
}
