@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@400;600;700&display=swap');

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --accent: #6366f1;
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-blur: blur(12px);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 0.5rem 1rem 2rem 1rem;
    color: var(--text-main);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

h1 {
    font-family: 'Outfit', sans-serif;
    text-align: center;
    font-size: 1.85rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.subtitle {
    text-align: center;
    color: #888;
    font-size: 0.65rem;
    margin-bottom: 1rem;
}

.glass-panel {
    background: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    border-radius: 16px;
}

.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.summary-card {
    padding: 0.8rem;
    text-align: center;
    transition: transform 0.3s;
}

.summary-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.2);
}

.summary-card .label {
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.summary-card .small-percent {
    font-size: 0.8rem;
    font-weight: 400;
    margin-left: 8px;
    opacity: 0.9;
}

.summary-card .value {
    font-size: 1.45rem;
    font-weight: 700;
    font-family: 'Outfit';
}

.table-wrapper {
    overflow-x: auto;
    padding: 0;
    margin-bottom: 2rem;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 4px;
}

th {
    padding: 12px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    vertical-align: middle;
}

tr td:first-child {
    border-radius: 12px 0 0 12px;
}

tr td:last-child {
    border-radius: 0 12px 12px 0;
}

tr.dragging td {
    background: rgba(99, 102, 241, 0.2);
    opacity: 0.5;
}

.stock-name {
    font-family: 'Outfit';
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
}

.ticker {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.stock-info-modal {
    max-width: 560px;
}

.stock-info-title-line {
    display: flex;
    align-items: center;
    gap: 10px;
}

.stock-info-live {
    margin-bottom: 0.6rem;
    font-size: 0.9rem;
}

.stock-info-meta {
    font-size: 0.68rem;
    margin-bottom: 0.75rem;
}

.stock-info-meta code {
    font-size: 0.65rem;
}

.stock-info-section h3 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 1rem 0 0.45rem;
    font-weight: 600;
}

.stock-info-section:first-of-type h3 {
    margin-top: 0.35rem;
}

.stock-info-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 0.25rem 0.75rem;
    font-size: 0.82rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    align-items: baseline;
}

.stock-info-label {
    color: var(--text-muted);
}

.stock-info-value {
    text-align: right;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.stock-info-link {
    margin-top: 1rem;
}


.stock-info-title-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  
  #stockInfoMorningstar {
    position: relative;
    top: -9px;
  }

.ms-mini {
    display: inline-grid;
    grid-template-columns: repeat(3, 6px);
    grid-template-rows: repeat(3, 6px);
    gap: 1px;
    margin: 0;
}

.ms-mini-cell {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.18);
}

.ms-mini-cell.active {
    background: #a3e635;
}



.consensus-simple {
    margin-top: 0.45rem;
}

.consensus-simple-track {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        #22c55e 0%,
        #22c55e 20%,
        #84cc16 20%,
        #84cc16 40%,
        #eab308 40%,
        #eab308 60%,
        #f59e0b 60%,
        #f59e0b 80%,
        #ef4444 80%,
        #ef4444 100%
    );
    overflow: hidden;
}

.consensus-simple-marker {
    position: absolute;
    top: -2px;
    width: 3px;
    height: 14px;
    background: #f8fafc;
    transform: translateX(-50%);
    border-radius: 2px;
}

.consensus-simple-meta {
    margin-top: 4px;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 2px;
    font-size: 0.55rem;
    color: var(--text-muted);
    text-align: center;
}

.consensus-simple-score {
    margin-top: 4px;
    font-size: 0.66rem;
    text-align: right;
    color: #e2e8f0;
}

.stock-info-link a {
    color: var(--accent);
    font-weight: 500;
    text-decoration: none;
}

.stock-info-link a:hover {
    text-decoration: underline;
}

.isin {
    color: var(--text-muted);
    font-size: 0.7rem;
}

.neutral {
    color: #888;
    font-size: 0.65rem;
    font-weight: 400;
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

.blue {
    color: #38bdf8;
}

.text-right { text-align: right; }
.text-left { text-align: left; }
.text-center { text-align: center; }

.price-white {
    color: #ffffff;
    font-weight: 700;
}

.actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn {
    padding: 10px 20px;
    border-radius: 14px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(8px);
}

.btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-refresh {
    color: #818cf8;
    border-color: rgba(129, 140, 248, 0.2);
    background: rgba(129, 140, 248, 0.05);
}

.btn-refresh:hover {
    border-color: rgba(129, 140, 248, 0.4);
    background: rgba(129, 140, 248, 0.1);
    color: #a5b4fc;
}

.btn-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.8), rgba(5, 150, 105, 0.8));
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #fff;
}

.btn-success:hover {
    background: linear-gradient(135deg, rgba(16, 185, 129, 1), rgba(5, 150, 105, 1));
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, rgba(244, 63, 94, 0.8), rgba(225, 29, 72, 0.8));
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fff;
}

.btn-danger:hover {
    background: linear-gradient(135deg, rgba(244, 63, 94, 1), rgba(225, 29, 72, 1));
    box-shadow: 0 0 20px rgba(244, 63, 94, 0.2);
}

.modal, .login-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 16px;
}

.modal.active, .login-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.login-overlay.active {
    align-items: flex-start;
    justify-content: center;
    padding-top: 8vh;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.login-content {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(25px);
    padding: 3rem 2rem;
    border-radius: 30px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7);
    margin-top: 0;
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.login-content h2 {
    font-family: 'Outfit';
    font-size: 2.2rem;
    margin-bottom: 2rem;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.login-content input {
    text-align: center;
    font-size: 1.4rem;
    letter-spacing: 0.3em;
    margin-bottom: 2rem;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
}

.modal-content {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(20px);
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    background: linear-gradient(to right, #818cf8, #c084fc);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
}

.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 0.95rem;
    transition: all 0.3s;
    outline: none;
}

input:focus {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.6);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 2rem;
}

/* Copy feedback animation */
.copy-feedback {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    z-index: 10000;
    pointer-events: none;
    animation: fadeInOut 2s forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, 20px); }
    15% { opacity: 1; transform: translate(-50%, 0); }
    85% { opacity: 1; transform: translate(-50%, 0); }
    100% { opacity: 0; transform: translate(-50%, -20px); }
}

.chart-cell {
    width: 250px;
    height: 75px;
    cursor: pointer;
    position: relative;
}

.chart-range-label {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 0.6rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 4px;
    border-radius: 4px;
    pointer-events: none;
    text-transform: uppercase;
}

.chart-cell canvas {
    width: 100%;
    height: 100%;
}

.flag {
    margin-right: 8px;
}

.comment-icon {
    margin-left: 8px;
    cursor: help;
    opacity: 0.7;
    position: relative;
    font-size: 1.1rem;
}

.comment-icon:hover {
    opacity: 1;
}

.comment-icon:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    min-width: 150px;
    max-width: 250px;
    z-index: 1000;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.action-btns {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
}

.comment-indicator, .trend-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.comment-indicator {
    background: var(--accent);
    cursor: help;
    box-shadow: 0 0 8px var(--accent);
    animation: pulse-glow-blue 2s infinite;
}

.trend-indicator {
    background: #fbbf24; /* Amarillo cálido */
    box-shadow: 0 0 8px #fbbf24;
    animation: pulse-glow-yellow 2s infinite;
}

@keyframes pulse-glow-blue {
    0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

@keyframes pulse-glow-yellow {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(251, 191, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.comment-indicator:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 150%;
    right: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    color: #fff;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: pre-wrap;
    width: max-content;
    max-width: 220px;
    z-index: 1000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    line-height: 1.4;
    font-family: 'Inter', sans-serif;
}

.btn-action {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-action:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Sensitive data hiding */
.summary-card { cursor: pointer; }
.sensitive { transition: filter 0.3s, opacity 0.3s; }
body.hide-sensitive .sensitive {
    filter: blur(8px);
    opacity: 0.3;
    pointer-events: none;
}

/* Hover Chart Popup */
.chart-popup {
    position: fixed;
    z-index: 3000;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    padding: 15px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 350px;
    max-width: min(680px, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    transition: opacity 0.2s;
}

.chart-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.chart-popup-title {
    font-family: 'Outfit';
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--accent);
}

.chart-popup-canvas-container {
    height: 187.5px; /* 75 * 2.5 */
    width: 625px; /* 250 * 2.5 */
}

/* Mobile sizing: keep popups within viewport width */
@media (max-width: 480px) {
    .chart-popup {
        min-width: 0 !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
    }

    .chart-popup-canvas-container {
        width: 100% !important;
        height: 170px;
    }

    .day-range-popup {
        min-width: 0 !important;
        width: calc(100vw - 20px) !important;
        max-width: calc(100vw - 20px) !important;
    }

    .modal, .login-overlay {
        padding: 10px;
    }

    .modal-content, .login-content {
        width: 100%;
        max-width: none;
        border-radius: 16px;
        padding: 1.2rem;
        max-height: calc(100dvh - 20px);
    }

    .modal-actions {
        flex-wrap: wrap;
        justify-content: stretch;
    }

    .modal-actions .btn {
        flex: 1 1 100%;
        justify-content: center;
    }

    .chart-popup-stats {
        grid-template-columns: 1fr;
    }
}

.chart-popup-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    font-size: 0.8rem;
}

.chart-popup-stat {
    display: flex;
    justify-content: space-between;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.chart-popup-stat .stat-label {
    color: var(--text-muted);
}

.chart-popup-stat .stat-value {
    font-weight: 600;
    color: var(--text-main);
}

.day-range-cell {
    cursor: pointer;
}

.day-range-popup {
    min-width: 420px;
}

.day-range-visual {
    padding: 16px 8px 6px;
}

.day-range-loading {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.range-scale {
    position: relative;
    height: 64px;
    width: 100%;
    margin: 8px 6px 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

.range-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 28px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    z-index: 1;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 8px 24px rgba(0, 0, 0, 0.18);
}

.range-track::before,
.range-track::after {
    content: '';
    position: absolute;
    top: -6px;
    width: 4px;
    height: 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    z-index: 4;
    box-shadow: 0 0 12px rgba(255, 255, 255, 0.18);
}

.range-track::before {
    left: 0;
}

.range-track::after {
    right: 0;
}

.range-band {
    position: absolute;
    top: 23px;
    height: 14px;
    border-radius: 8px;
    z-index: 3;
}

.month-band {
    background: #4f46e5;
    opacity: 0.55;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.day-band {
    background: #0ea5e9;
    height: 24px;
    top: 18px;
    opacity: 0.85;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.range-marker {
    position: absolute;
    top: -8px;
    transform: translateX(-50%);
    z-index: 5;
}

.range-marker-triangle {
    width: 0;
    height: 0;
    margin: 0 auto;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 22px solid #facc15;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.55));
}

.range-marker-label {
    margin-bottom: 4px;
    color: #f8fafc;
    font-size: 0.72rem;
    text-align: center;
    white-space: nowrap;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
    font-weight: 600;
}

.range-end-label {
    position: absolute;
    top: 42px;
    font-size: 0.7rem;
    color: var(--text-muted);
    z-index: 6;
    text-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

.range-end-label-left {
    left: 0;
}

.range-end-label-right {
    right: 0;
}

.range-legend {
    display: flex;
    gap: 14px;
    margin-top: 12px;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 8px;
    margin-right: 6px;
    vertical-align: middle;
}

.legend-month {
    background: #4f46e5;
}

.legend-day {
    background: #0ea5e9;
}

.legend-current {
    width: 0;
    height: 0;
    margin-right: 8px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 10px solid #facc15;
}