:root {
  --bg: #07070c;
  --surface: #101018;
  --surface2: #181822;
  --surface-elevated: rgba(24, 24, 36, 0.72);
  --border: #2a2a3c;
  --accent: #c8ff00;
  --accent-dim: rgba(200, 255, 0, 0.14);
  --red: #ff3b5c;
  --green: #00e87a;
  --text: #ececf4;
  --muted: #8b8ba8;
  --win: #00e87a;
  --loss: #ff3b5c;
  --pending: #c8ff00;
  --radius: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "DM Mono", ui-monospace, monospace;
  --font-display: "Bebas Neue", Impact, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.45;
}

/* Sin sesión: la app no existe en pantalla (evita scroll bajo el login) */
html.auth-pending body {
  overflow: hidden;
}

html.auth-pending .app-shell {
  display: none !important;
}

.bg-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 120% 80% at 10% -10%, rgba(200, 255, 0, 0.12), transparent 50%),
    radial-gradient(ellipse 90% 60% at 100% 20%, rgba(255, 107, 53, 0.08), transparent 45%),
    radial-gradient(ellipse 70% 50% at 50% 100%, rgba(80, 120, 255, 0.06), transparent 55%),
    var(--bg);
}

.bg-mesh::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
  opacity: 0.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0.5rem;
  z-index: 100;
  padding: 0.5rem 1rem;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  border-radius: 8px;
}

.skip-link:focus {
  left: 0.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.25rem) clamp(1rem, 3vw, 1.75rem) 2rem;
}

/* Header */
.site-header {
  display: grid;
  gap: 1.5rem;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

@media (min-width: 768px) {
  .site-header {
    grid-template-columns: 1fr auto;
    align-items: end;
  }
}

.brand-block .logo {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 10vw, 5rem);
  line-height: 0.92;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-shadow: 0 0 48px rgba(200, 255, 0, 0.28);
}

.brand-block .logo span {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.34em;
  color: var(--muted);
  letter-spacing: 0.22em;
  font-family: var(--font-mono);
  font-weight: 500;
}

.tagline {
  margin-top: 0.75rem;
  max-width: 28rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}

@media (min-width: 768px) {
  .header-actions {
    align-items: flex-end;
  }
}

.session-date {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  text-align: left;
  line-height: 1.65;
}

@media (min-width: 768px) {
  .session-date {
    text-align: right;
  }
}

.session-date strong {
  color: var(--accent);
  font-weight: 600;
}

.user-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
}

@media (min-width: 768px) {
  .user-bar {
    justify-content: flex-end;
  }
}

.user-select {
  flex: 1 1 140px;
  min-width: 0;
  max-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.55rem 0.85rem;
  outline: none;
  cursor: pointer;
}

.user-select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.btn-ghost:hover {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
}

.btn-ghost:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-file {
  cursor: pointer;
}

.btn-file input {
  display: none;
}

/* Stats — panel tipo bento */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

@media (min-width: 640px) {
  .stats-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1100px) {
  .stats-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

.stat-cell {
  background: linear-gradient(165deg, rgba(22, 22, 34, 0.95) 0%, rgba(14, 14, 22, 0.98) 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1rem 1.05rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

.stat-cell:hover {
  border-color: rgba(200, 255, 0, 0.22);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 0.45rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4.5vw, 2rem);
  line-height: 1;
}

.stat-value.green {
  color: var(--green);
}
.stat-value.red {
  color: var(--red);
}
.stat-value.accent {
  color: var(--accent);
}
.stat-value.white {
  color: var(--text);
}

.stat-cell--editable {
  position: relative;
}

.stat-cell--editable .stat-body {
  min-height: 2.25rem;
  display: flex;
  align-items: center;
}

.stat-edit-pencil {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.2rem 0.35rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.stat-cell--editable:hover .stat-edit-pencil,
.stat-cell--editable:focus-within .stat-edit-pencil,
.stat-cell--editable.is-editing .stat-edit-pencil {
  opacity: 1;
}

.stat-edit-pencil:hover {
  color: var(--accent);
  background: rgba(200, 255, 0, 0.08);
}

.stat-edit-pencil:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  opacity: 1;
}

@media (hover: none) and (pointer: coarse) {
  .stat-cell--editable .stat-edit-pencil {
    opacity: 0.55;
  }

  .stat-cell--editable:active .stat-edit-pencil,
  .stat-cell--editable.is-editing .stat-edit-pencil {
    opacity: 1;
  }
}

.stat-cell--editable .stat-input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0.2rem 0.45rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.8vw, 1.75rem);
  line-height: 1.2;
  color: var(--text);
  background: rgba(10, 10, 16, 0.95);
  border: 1px solid rgba(200, 255, 0, 0.45);
  border-radius: 8px;
}

.stat-cell--editable .stat-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(200, 255, 0, 0.15);
}

/* Progress */
.progress-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.panel-progress {
  margin-bottom: 1.75rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
  gap: 1rem;
}

.progress-title {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.progress-pct {
  font-family: var(--font-display);
  font-size: 1.45rem;
  color: var(--accent);
}

.progress-bar-bg {
  height: 10px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), #9fe020);
  transition: width 0.65s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}

.progress-bar-fill::after {
  content: "";
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 12px var(--accent);
}

/* Nueva apuesta — tarjeta compacta */
.bet-form {
  position: relative;
  margin-bottom: 0;
  padding: 1.15rem 1.2rem 1.25rem;
  border-radius: calc(var(--radius) + 2px);
  background: linear-gradient(145deg, rgba(22, 22, 34, 0.98) 0%, rgba(12, 12, 20, 1) 100%);
  border: 1px solid rgba(200, 255, 0, 0.12);
  box-shadow:
    0 20px 56px rgba(0, 0, 0, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.bet-form::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(200, 255, 0, 0.28), transparent 42%, rgba(120, 120, 180, 0.12));
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  opacity: 0.75;
}

.bet-form__head {
  position: relative;
  z-index: 1;
  margin-bottom: 1rem;
}

.bet-form__title {
  font-family: var(--font-display);
  font-size: 1.42rem;
  color: var(--accent);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.15;
}

.bet-form__lead {
  margin-top: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
  max-width: 36ch;
}

.bet-form__grid {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

.bet-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}

.bet-field__label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.bet-field__input {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.95rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(6, 6, 12, 0.92);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.92rem;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s,
    background 0.2s;
}

.bet-field__input:hover {
  border-color: rgba(200, 255, 0, 0.22);
}

.bet-field__input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: rgba(8, 8, 16, 0.98);
}

.bet-field__input::placeholder {
  color: rgba(139, 139, 168, 0.75);
}

.bet-field__input--match {
  min-height: 3.15rem;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}

.bet-field__select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%238b8ba8'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.25rem;
}

.bet-field--span {
  grid-column: 1 / -1;
}

.bet-form__cta {
  grid-column: 1 / -1;
  justify-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  max-width: none;
  min-height: 3rem;
  margin-top: 0.15rem;
  padding: 0.75rem 1.25rem;
  border-radius: 12px;
  white-space: nowrap;
}

.bet-form__cta-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 8px;
  background: rgba(10, 10, 18, 0.35);
  font-size: 1.25rem;
  line-height: 1;
  font-weight: 700;
}

.bet-form__cta-text {
  font-size: 1.08rem;
}

@media (min-width: 560px) {
  .bet-form__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .bet-field--span {
    grid-column: 1 / -1;
  }

  .bet-form__cta {
    grid-column: 1 / -1;
  }
}

@media (min-width: 560px) and (max-width: 899px) {
  .bet-field--wide-tablet {
    grid-column: 1 / -1;
  }
}

@media (min-width: 900px) {
  .bet-form__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem 0.85rem;
    align-items: end;
  }

  .bet-field--span {
    grid-column: 1 / -1;
  }

  .bet-form__cta {
    grid-column: 1 / -1;
    margin-top: 0.35rem;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.field input,
.field select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.88rem;
  padding: 0.62rem 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  width: 100%;
}

.field input:focus-visible,
.field select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field input::placeholder {
  color: var(--muted);
}

.btn-add {
  background: var(--accent);
  color: #0a0a0f;
  border: none;
  border-radius: 10px;
  padding: 0.72rem 1.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: 0.07em;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  white-space: nowrap;
}

.btn-add:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(200, 255, 0, 0.35);
}

.btn-add:active {
  transform: translateY(0);
}

.btn-add:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.btn-add--small {
  padding: 0.55rem 1rem;
  font-size: 0.95rem;
}

/* Table section */
.table-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.table-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.table-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  color: var(--text);
}

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 0.45rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.btn-clear:hover {
  border-color: var(--red);
  color: var(--red);
}

.desktop-only {
  display: none;
}

@media (min-width: 768px) {
  .desktop-only {
    display: block;
  }
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg);
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

@keyframes rowSlide {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

tbody tr {
  animation: rowSlide 0.35s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

tbody td {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.8rem 1rem;
  vertical-align: middle;
}

.td-apuesta {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.88rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.28rem 0.65rem;
  border-radius: 99px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.badge-win {
  background: rgba(0, 232, 122, 0.14);
  color: var(--win);
  border: 1px solid rgba(0, 232, 122, 0.28);
}

.badge-loss {
  background: rgba(255, 59, 92, 0.14);
  color: var(--loss);
  border: 1px solid rgba(255, 59, 92, 0.28);
}

.badge-pending {
  background: rgba(200, 255, 0, 0.1);
  color: var(--pending);
  border: 1px solid rgba(200, 255, 0, 0.22);
}

.diff-pos {
  color: var(--green);
}
.diff-neg {
  color: var(--red);
}
.diff-zero {
  color: var(--muted);
}

.btn-result {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--muted);
  transition: all 0.15s;
  margin-right: 0.25rem;
  min-height: 36px;
  min-width: 36px;
}

.btn-result:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-win:hover {
  border-color: var(--green) !important;
  color: var(--green) !important;
}

.btn-loss:hover {
  border-color: var(--red) !important;
  color: var(--red) !important;
}

.btn-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  transition: color 0.15s;
  line-height: 1;
  min-width: 40px;
  min-height: 40px;
}

.btn-delete:hover {
  color: var(--red);
}

.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.empty-icon {
  font-size: 2.25rem;
  margin-bottom: 0.75rem;
  display: block;
  opacity: 0.45;
}

/* Mobile cards */
.bets-mobile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 1.1rem 1.25rem;
}

@media (min-width: 768px) {
  .bets-mobile {
    display: none;
  }
}

.bet-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.05rem;
  display: grid;
  gap: 0.65rem;
}

.bet-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.bet-card-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.25;
  word-break: break-word;
}

.bet-card-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.bet-card-meta span {
  color: var(--text);
  font-weight: 500;
}

.bet-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

/* Chart */
.chart-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem;
  margin-bottom: 1.25rem;
}

.chart-section--aside {
  margin-bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 280px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}

.chart-section--aside .chart-wrap {
  flex: 1;
  display: flex;
  align-items: stretch;
  min-height: 220px;
}

.chart-section--aside #chartCanvas {
  flex: 1;
  min-height: 240px;
}

.chart-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.05em;
  margin-bottom: 1rem;
  color: var(--text);
}

.chart-wrap {
  width: 100%;
  min-height: 200px;
}

#chartCanvas {
  width: 100%;
  height: auto;
  min-height: 180px;
  display: block;
}

@media (min-width: 768px) {
  .chart-wrap {
    min-height: 220px;
  }
  #chartCanvas {
    min-height: 200px;
  }
}

/* Dos columnas: formulario + gráfico (desktop) */
.layout-split {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 1024px) {
  .layout-split {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
    align-items: start;
    gap: 1.35rem;
  }

  .layout-split__aside {
    position: sticky;
    top: 5.5rem;
    align-self: start;
    max-height: calc(100vh - 6rem);
    overflow: auto;
  }
}

.site-footer {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  padding: 1.25rem 0;
  opacity: 0.65;
}

/* Toast */
.toast-host {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
  width: min(92vw, 360px);
}

.toast {
  pointer-events: none;
  background: rgba(20, 20, 32, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-align: center;
  box-shadow: var(--shadow);
  animation: toastIn 0.35s ease;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Modal */
.modal {
  border: none;
  padding: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  max-width: min(440px, 94vw);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-inner {
  padding: 1.35rem 1.4rem 1.5rem;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.modal-head h2 {
  font-family: var(--font-display);
  font-size: 1.45rem;
  letter-spacing: 0.05em;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.add-user-form label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.add-user-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.15rem;
}

.add-user-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: var(--font-sans);
  padding: 0.55rem 0.85rem;
  outline: none;
}

.add-user-row input:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.user-list {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
}

.user-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.user-item:last-child {
  border-bottom: none;
}

.user-item-name {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.user-item-name strong {
  color: var(--accent);
  font-weight: 600;
}

.user-item-actions {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.btn-icon:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-mini {
  padding: 0.35rem 0.55rem;
  font-size: 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.btn-mini:hover {
  border-color: var(--red);
  color: var(--red);
}

.btn-mini--danger {
  border-color: rgba(255, 59, 92, 0.35);
}

.btn-ghost--danger:hover {
  border-color: var(--red);
  color: var(--red);
}

.cloud-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.45rem 0.75rem;
  border-radius: 99px;
  border: 1px solid rgba(200, 255, 0, 0.28);
  background: rgba(200, 255, 0, 0.06);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text);
  max-width: min(100%, 220px);
  word-break: break-all;
}

.cloud-pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  flex-shrink: 0;
}

.modal--wide {
  max-width: min(480px, 96vw);
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  flex: 1;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.auth-tab.is-active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(200, 255, 0, 0.06);
}

.auth-panel .field {
  margin-bottom: 0.75rem;
}

.auth-submit {
  width: 100%;
  margin-top: 0.25rem;
}

.auth-alt {
  margin-top: 0.85rem;
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  text-decoration: underline;
}

.checkbox-row {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
  line-height: 1.45;
}

.checkbox-row input {
  margin-top: 0.25rem;
  flex-shrink: 0;
}

.checkbox-row a {
  color: var(--accent);
}

.auth-api-hint {
  margin-top: 1rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.auth-form-error {
  margin-top: 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.82rem;
  line-height: 1.4;
  background: rgba(255, 59, 92, 0.12);
  border: 1px solid rgba(255, 59, 92, 0.4);
  color: #ffc9d4;
}

.auth-form-error[hidden] {
  display: none !important;
}

.auth-field-hint {
  margin: -0.35rem 0 0.65rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--font-mono);
  line-height: 1.35;
}

.legal-section {
  margin-top: 2rem;
  padding: 1.35rem 1.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(16, 16, 24, 0.55);
}

.legal-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.legal-body p {
  font-size: 0.88rem;
  color: var(--muted);
  margin-bottom: 0.65rem;
  line-height: 1.55;
}

.legal-body p:last-child {
  margin-bottom: 0;
}

.reset-page .logo span {
  display: none;
}

.reset-form {
  max-width: 420px;
}

/* ========== Pantalla de acceso ========== */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.5rem, 5vw, 3rem) 1rem;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-gate-inner {
  width: min(440px, 100%);
}

.auth-gate-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-gate-logo {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 12vw, 4rem);
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(200, 255, 0, 0.25);
  letter-spacing: 0.02em;
}

.auth-gate-tagline {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.auth-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}

.app-shell {
  position: relative;
  z-index: 1;
}

/* ========== Navbar (una sola barra) ========== */
.navbar-wrap {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(3, 3, 8, 0.94);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.navbar-one {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  padding: 0.38rem clamp(0.75rem, 3vw, 1.25rem);
  max-width: 1200px;
  margin: 0 auto;
}

.navbar-brand--row {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.navbar-logo {
  font-family: var(--font-display);
  font-size: 1.18rem;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.navbar-sub-inline {
  font-family: var(--font-mono);
  font-size: 0.52rem;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.navbar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  margin-left: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.navbar-toggle-bar {
  display: block;
  width: 17px;
  height: 2px;
  margin: 0 auto;
  background: var(--text);
  border-radius: 1px;
}

.navbar-menu {
  display: none;
  flex-direction: column;
  gap: 0.55rem;
  flex-basis: 100%;
  width: 100%;
}

.navbar-menu.is-open {
  display: flex;
}

.navbar-rail {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.08rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 0.15rem 0;
}

.navbar-rail::-webkit-scrollbar {
  height: 3px;
}

.nav-pill {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 0.32rem 0.62rem;
  border-radius: 8px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}

.nav-pill:hover {
  color: var(--text);
  background: rgba(200, 255, 0, 0.08);
}

.nav-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.navbar-cluster {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.45rem;
}

.navbar-meta {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--muted);
  line-height: 1.35;
  word-break: break-word;
}

.navbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.user-select--nav {
  max-width: min(11rem, 42vw);
  padding: 0.42rem 0.65rem;
  font-size: 0.72rem;
}

.btn-toolbar {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.42rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.15s, background 0.15s;
}

.btn-toolbar:hover {
  border-color: var(--muted);
  background: rgba(255, 255, 255, 0.07);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  list-style: none;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  padding: 0.42rem 0.75rem;
  border-radius: 9px;
  border: 1px solid rgba(200, 255, 0, 0.35);
  background: rgba(200, 255, 0, 0.06);
  transition: background 0.15s, border-color 0.15s;
}

.nav-dropdown-btn::-webkit-details-marker {
  display: none;
}

.nav-dropdown-btn:hover {
  background: rgba(200, 255, 0, 0.1);
}

.nav-dropdown-body {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  z-index: 90;
  min-width: min(220px, calc(100vw - 1.5rem));
  padding: 0.35rem;
  background: rgba(10, 10, 18, 0.98);
  border: 1px solid var(--border);
  border-radius: 11px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
}

.nav-dropdown-item {
  width: 100%;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.52rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-dropdown-item--danger:hover {
  background: rgba(255, 59, 92, 0.12);
  color: var(--red);
}

.nav-dropdown-item--accent {
  margin-top: 0.15rem;
  color: var(--accent);
  border: 1px solid rgba(200, 255, 0, 0.35);
}

.nav-dropdown-item--accent:hover {
  background: rgba(200, 255, 0, 0.08);
}

.page-intro {
  margin-bottom: clamp(1.35rem, 4vw, 2rem);
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(42, 42, 60, 0.65);
}

.page-intro-title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  letter-spacing: 0.04em;
  color: var(--text);
  font-weight: 400;
  line-height: 1.05;
}

.page-intro-lead {
  margin-top: 0.5rem;
  font-size: 0.94rem;
  color: var(--muted);
  max-width: 38rem;
  line-height: 1.5;
}

.lead-intro {
  font-size: 0.92rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
  max-width: 36rem;
}

.container-app {
  padding-top: clamp(1rem, 3vw, 1.75rem);
}

@media (max-width: 960px) {
  .navbar-toggle {
    display: flex;
  }

  .navbar-tools {
    width: 100%;
    justify-content: stretch;
  }

  .navbar-tools .user-select--nav,
  .navbar-tools .btn-toolbar {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav-dropdown {
    flex: 1 1 auto;
    min-width: 0;
  }

  .nav-dropdown-btn {
    width: 100%;
    text-align: center;
  }

  .nav-dropdown-body {
    position: static;
    margin-top: 0.35rem;
    width: 100%;
    min-width: 0;
  }

  .cloud-pill {
    width: 100%;
    max-width: none;
    justify-content: center;
  }
}

@media (min-width: 961px) {
  .navbar-one {
    flex-wrap: nowrap;
  }

  .navbar-toggle {
    display: none !important;
  }

  .navbar-menu {
    display: flex !important;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    flex-basis: auto;
  }

  .navbar-rail {
    flex: 1 1 auto;
    min-width: 0;
  }

  .navbar-cluster {
    flex-direction: row;
    align-items: center;
    gap: 0.65rem;
    flex-shrink: 0;
    max-width: min(480px, 48%);
  }

  .navbar-meta {
    font-size: 0.6rem;
    text-align: right;
    max-width: 14rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .navbar-tools {
    flex-shrink: 0;
  }
}
