:root {
    --bg-dark: #0f1012;
    --surface: rgba(28, 30, 34, 0.95);
    --input: #25282d;
    --text: #ffffff;
    --muted: #8a8c92;
    --accent: #5865f2;
    --accent-hover: #4752c4;
    --success: #3ba55c;
    --error: #ed4245;
    --radius: 14px;
    --btn-height: 42px;
}

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

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 12px 30px;
    position: relative;
    line-height: 1.5;
}

.fixed-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-image: url('hcr2lgds.jpg');
    background-position: center bottom;
    background-repeat: no-repeat;
    background-size: cover;
    z-index: -1;
    opacity: 0.4;
    pointer-events: none;
}

.main-wrapper {
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    padding: 20px 20px 40px;
    background-color: #4752c4;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.screen { display: none; width: 100%; animation: fadeIn 0.3s ease; }
.screen.active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0 5px;
}

.header-logo { display: flex; align-items: center; gap: 15px; }

.team-logo {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: none;
}

.main-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9);
    letter-spacing: 0.5px;
    font-variant: petite-caps;
    color: var(--text);
    line-height: 1.2;
}

.card {
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius);
    padding: 25px 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    width: 100%;
}

.login-card { padding: 35px 30px; text-align: center; }

.header-actions { display: flex; align-items: center; gap: 10px; }

/* BOTONES */
button, .btn-primary, .btn-secondary, .btn-small, .btn-success, .btn-danger {
    height: var(--btn-height);
    width: 100%;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-variant: petite-caps;
    margin-top: 15px;
    margin-bottom: 15px;
    letter-spacing: 0.3px;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }

.btn-secondary { background: var(--input); color: var(--text); border: 1px solid #3a3d42; }
.btn-secondary:hover:not(:disabled) { background: #35383d; border-color: #4a4d52; }

.btn-small {
    width: auto;
    height: 36px;
    padding: 0 14px;
    font-size: 0.85rem;
    background: var(--input);
    color: var(--text);
    border: 1px solid #3a3d42;
}
.btn-small:hover { background: #35383d; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #2d7d46; transform: translateY(-1px); }

.btn-danger { background: var(--error); color: white; }
.btn-danger:hover:not(:disabled) { background: #c23b3d; transform: translateY(-1px); }

button:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* MENU OVERLAY */
.btn-menu {
    width: auto;
    height: 40px;
    padding: 0 12px;
    background: var(--input);
    color: var(--text);
    border: 1px solid #3a3d42;
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-menu:hover { background: #3a3d42; transform: scale(1.05); box-shadow: 0 0 8px rgba(88,101,242, 0.5); }

.menu-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.94);
    z-index: 1000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
    cursor: pointer;
}
.menu-overlay.active { display: flex; }

.menu-content {
    background: #0a0a0a;
    border-radius: 12px;
    padding: 30px;
    max-width: 95%;
    width: 450px;
    position: relative;
    cursor: default;
    box-shadow: none;
    border: none;
}

.menu-header { 
    position: absolute; 
    top: 10px; 
    right: 15px; 
    display: flex;
    align-items: center;
    gap: 10px;
}

.menu-logo {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.menu-close {
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
    transition: 0.2s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.menu-close:hover { color: var(--error); background: rgba(255,255,255,0.1); }

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}
.menu-list::-webkit-scrollbar { width: 4px; }
.menu-list::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 2px; }

.menu-item {
    padding: 12px 15px;
    margin: 4px 0;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    color: var(--text);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: 0.2s;
}
.menu-item span:first-child { font-size: 1.2em; }
.menu-item:hover { background: rgba(255,255,255,0.08); transform: translateX(5px); }
.menu-item.active { border-left: 4px solid var(--accent); background: rgba(88,101,242,0.15); }

/* TABS */
.tab-pane { display: none; animation: fadeIn 0.3s ease; }
.tab-pane.active { display: block; }

/* TÍTULOS */
.tab-title { font-size: 1.3rem; font-weight: 700; margin: 0 0 20px 0; color: var(--text); text-align: left; }
.chart-subtitle { font-size: 1rem; font-weight: 700; margin: 0 0 15px 0; color: var(--text); text-align: left; }
.config-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 15px; color: var(--text); text-align: left; }

/* FORMULARIOS */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-top: 15px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

label { font-weight: 700; font-size: 1rem; color: #bfbfbf; margin-bottom: 0px; }

input, select {
    width: 100%;
    height: var(--btn-height);
    padding: 0 12px;
    background: var(--input);
    border: 1px solid #3a3d42;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.92rem;
    font-family: inherit;
    transition: all 0.2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(88,101,242,0.2);
}

.period-selector {
    background: var(--input);
    color: var(--text);
    border: 1px solid #3a3d42;
    border-radius: 8px;
    padding: 8px;
    width: 100%;
    margin-top: 0px;
}

/* SLIDERS */
.slider-container { position: relative; margin: 20px 0; display: flex; align-items: center; }
.slider-track { display: flex; width: 100%; overflow: hidden; scroll-behavior: smooth; }
.slide { min-width: 100%; display: none; padding: 0 10px; animation: fadeIn 0.4s ease; }
.slide.active { display: block; }

.slider-arrow {
    width: 35px !important;
    height: 35px !important;
    background: transparent !important;
    border: none !important;
    color: var(--text) !important;
    border-radius: 8% !important;
    cursor: pointer !important;
    z-index: 10 !important;
    margin: 0 8px !important;
    font-size: 1.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    visibility: visible !important;
}
.slider-arrow:hover { background: none !important; transform: scale(1.1); }
.slider-arrow.right { right: -30px !important; position: absolute !important; }
.slider-arrow.left { left: -30px !important; position: absolute !important; }

/* STATS GRID */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--input); padding: 15px 10px; border-radius: 10px; text-align: center; transition: transform 0.2s; }
.stat-card:hover { transform: translateY(-3px); }
.stat-icon { font-size: 1.8rem; margin-bottom: 8px; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

/* CHARTS */
.chart-container { background: var(--input); border-radius: 8px; padding: 10px; margin-bottom: 10px; }

/* FORMULA BOX */
.formula-box {
    background: rgba(88,101,242,0.1);
    border-left: 4px solid var(--accent);
    padding: 20px;
    border-radius: 0 10px 10px 0;
    margin-top: 15px;
}
.formula-box h4 { margin: 0 0 12px; color: var(--accent); font-size: 1rem; }
.formula-box p { font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; line-height: 1.6; }
.formula-code {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 6px;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    color: #57f287;
    text-align: center;
}

/* INFO BOX */
.info-box {
    background: rgba(88, 101, 242, 0.1);
    border-left: 3px solid var(--accent);
    padding: 12px;
    margin-top: 15px;
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
}
.info-box p { margin: 5px 0; color: var(--muted); }

/* MODAL */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
}
.modal-content {
    background: var(--surface);
    padding: 25px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 10px; right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--muted);
}
.modal-close:hover { color: var(--error); }

/* TOOLTIP */
.tooltip { cursor: help; color: var(--accent); font-size: 0.8em; margin-left: 2px; }

/* OTHERS */
.subtitle { text-align: center; color: var(--muted); font-size: 1.05rem; margin-bottom: 8px; font-weight: 500; }
.status { text-align: center; margin-top: 12px; font-size: 0.85rem; min-height: 20px; font-weight: 500; }
.success { color: var(--success); }
.error { color: var(--error); }
.info-text { font-size: 0.85rem; color: var(--muted); margin-bottom: 18px; text-align: left; margin-top: 20px; }

.result-preview, .csv-preview {
    background: var(--input);
    border: 1px solid #3a3d42;
    border-radius: 8px;
    padding: 15px;
    margin: 15px 0;
    max-height: 250px;
    overflow-y: auto;
}
.result-preview pre, .csv-preview pre {
    margin: 0;
    font-family: 'Consolas', monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre-wrap;
    color: var(--text);
}

.queue-box {
    background: var(--input);
    border: 1px solid #3a3d42;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 15px;
    margin-top: 20px;
}
.queue-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; font-size: 0.95rem; }
.queue-number { color: var(--accent); font-weight: 700; font-size: 1.2rem; }

.sheets-link {
    text-decoration: none;
    background: var(--success);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    width: 100%;
    justify-content: center;
    margin-top: 10px;
}
.sheets-link:hover { background: #236b38; }

.app-footer { width: 100%; text-align: center; padding: 15px 0 0; margin-top: 10px; }

.discord-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
}
.discord-link:hover { background: none; color: #5865f2; }
.discord-icon { font-size: 1.2rem; }
.discord-text { font-variant: petite-caps; letter-spacing: 0.3px; }

.loading-text { text-align: center; color: var(--muted); padding: 30px; }
#exportBtn { margin-top: 15px; }
.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }

code {
    background: var(--input);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    color: var(--accent);
}

/* NOMINEES */
.nominees-list { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; }
.nominee-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 15px;
    background: var(--surface);
    border-radius: 8px;
    font-size: 0.9rem;
    border-left: 3px solid var(--accent);
}
.nominee-name { font-weight: 600; color: var(--text); }
.nominee-stats { color: var(--muted); font-size: 0.85rem; }

/* Radio buttons responsive: columna en móvil */
.radio-group { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.radio-group label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    margin: 8px 0;
}
.radio-group input[type="radio"] {
    width: 14px;
    height: 14px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

@media (max-width: 600px) {
    .radio-group { flex-direction: column !important; gap: 15px !important; }
    .radio-group label { margin: 8px 0 !important; padding: 8px 0 !important; border-bottom: 1px solid #3a3d42 !important; }
    .radio-group label:last-child { border-bottom: none !important; }
}

/* Logout button */
#logout-btn { font-size: 0.85rem; padding: 6px 12px; font-variant: small-caps; letter-spacing: 1px; }
#logout-btn span:first-child { opacity: 0.9; font-weight: 500; }

/* Ajustes inputs */
.form-row .form-group input,
.form-row .form-group select { width: 100%; }

/* Botón cerrar menú */
span#menuClose { margin-right: -20px; font-size: 1.5rem; padding: 8px; border-radius: 15px; }
span#menuClose:hover { color: #5865F2; background-color: #3c3c3c; }

/* ✅ NUEVO: Logo del menú centrado y más grande */
.menu-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    position: relative;
}

.menu-logo-top {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    margin-bottom: 10px;
}

.menu-close-btn {
    position: absolute;
    top: 0;
    right: 0;
    font-size: 1.5rem;
    color: var(--muted);
    cursor: pointer;
    transition: 0.2s;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.menu-close-btn:hover { color: var(--error); background: rgba(255,255,255,0.1); }

/* Responsive general */
@media (min-width: 768px) {
    .main-wrapper { max-width: 700px; padding: 30px 30px 50px; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); }
    .card { padding: 30px 25px; }
}

@media (max-width: 767px) {
    body { padding: 20px 12px 30px; }
    .main-wrapper { max-width: 100%; padding: 15px 15px 30px; gap: 18px; }
    .main-title { font-size: 1.1rem; }
    .team-logo { width: 55px; height: auto; border-radius: 5px; object-fit: contain; box-shadow: none; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    :root { --btn-height: 40px; }
}

@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 1.1rem; }
    .menu-item { font-size: 1rem; padding: 10px 12px; }
}

/* ──────────────────────────────────────────────────────────────
   DETECTOR DE TIPO CSV
   ────────────────────────────────────────────────────────────── */
#csvTypeDetector {
    padding: 10px;
    background: rgba(88, 101, 242, 0.1);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-size: 0.85rem;
    margin-bottom: 10px;
}

/* ──────────────────────────────────────────────────────────────
   LOGO CLICABLE
   ────────────────────────────────────────────────────────────── */
.header-logo {
    cursor: pointer;
    transition: opacity 0.2s;
}

.header-logo:hover {
    opacity: 0.8;
}

.menu-logo-top {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    margin-bottom: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.menu-logo-top:hover {
    transform: scale(1.05);
}

/* ──────────────────────────────────────────────────────────────
   HISTÓRICO DE JUGADOR
   ───────────────────────────────────────────────────────────── */
#historyStats .stats-grid {
    grid-template-columns: repeat(3, 1fr) !important;
}

#historyStats .stat-card {
    padding: 10px;
}

#historyStats .stat-value {
    font-size: 1.1rem;
}

#historyStats .stat-label {
    font-size: 0.7rem;
}

/* ─────────────────────────────────────────────────────────────
   NOTIFICACIONES
   ───────────────────────────────────────────────────────────── */
.notifications-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999;
    background: var(--surface);
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 8px;
}

.notifications-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.notifications-toggle label {
    font-size: 1.2rem;
    cursor: pointer;
    margin: 0;
}

.notif-bubble {
    position: fixed;
    top: 20px;
    right: 80px;
    background: var(--error);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    z-index: 998;
    box-shadow: 0 2px 8px rgba(237, 66, 69, 0.5);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.notifications-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 320px;
    max-height: 400px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 997;
    overflow: hidden;
}

.notif-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--accent);
    color: white;
}

.notif-header h4 {
    margin: 0;
    font-size: 0.95rem;
}

.notif-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    margin: 0;
}

.notif-list {
    max-height: 340px;
    overflow-y: auto;
    padding: 10px;
}

.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid #3a3d42;
    cursor: pointer;
    transition: background 0.2s;
}

.notif-item:hover {
    background: rgba(88, 101, 242, 0.1);
}

.notif-icon {
    font-size: 1.5rem;
}

.notif-content p {
    margin: 0 0 4px 0;
    font-size: 0.85rem;
    color: var(--text);
}

.notif-content small {
    color: var(--muted);
    font-size: 0.75rem;
}

/* ─────────────────────────────────────────────────────────────
   PERMISOS
   ───────────────────────────────────────────────────────────── */
.permissions-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.perm-level {
    padding: 12px;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}

.perm-level h4 {
    margin: 0 0 6px 0;
    font-size: 0.95rem;
}

.perm-level p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted);
}

.perm-admin { background: rgba(237, 66, 69, 0.1); border-color: var(--error); }
.perm-lider { background: rgba(240, 178, 50, 0.1); border-color: #f0b232; }
.perm-colider { background: rgba(88, 101, 242, 0.1); border-color: var(--accent); }
.perm-legendario { background: rgba(59, 165, 92, 0.1); border-color: var(--success); }

.user-item {
    padding: 10px;
    border-bottom: 1px solid #3a3d42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.role-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-active { background: var(--success); color: white; }
.role-paused { background: #f0b232; color: black; }
.role-ex-legendario { background: var(--error); color: white; }

/* ──────────────────────────────────────────────────────────────
   SELECTOR DE PERIODO
   ───────────────────────────────────────────────────────────── */
.period-view-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
}

.period-btn {
    flex: 1;
    padding: 10px 15px;
    background: var(--input);
    color: var(--text);
    border: 2px solid #3a3d42;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin: 0;
}

.period-btn:hover {
    background: #35383d;
    border-color: var(--accent);
}

.period-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.period-help-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--muted);
    margin-bottom: 15px;
    font-style: italic;
}