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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    padding: 20px;
    color: #fff;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header p {
    color: #888;
    margin-top: 10px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-card h3 {
    font-size: 0.9rem;
    color: #aaa;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: bold;
}

.stat-card .stat-small-info {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #c9d2e3;
}

.stat-card .metric-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #aeb8c9;
}

.stat-card .metric-value {
    font-size: 1rem;
    color: #fff;
    font-weight: 700;
}

.stat-card .value.positive {
    color: #00ff88;
}

.stat-card .value.negative {
    color: #ff4444;
}

.stat-inline-values {
    display: flex;
    align-items: flex-end;
    gap: 18px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.stat-inline-item {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    min-width: 0;
    flex: 1 1 120px;
}

.capital-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 12px;
}

.capital-detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    min-height: 60px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.capital-delta.positive {
    color: #00ff88;
}

.capital-delta.negative {
    color: #ff4444;
}

.stat-inline-value {
    color: #fff;
    font-size: 2rem;
    line-height: 1;
}

.stat-inline-value-euro {
    font-size: 1.45rem;
}

.stat-inline-symbol {
    color: #c9d2e3;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.stat-inline-symbol-euro {
    font-size: 1.15rem;
}

.stat-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    margin-top: 12px;
}

.stat-summary-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.stat-summary-label {
    font-size: 0.74rem;
    color: #aeb8c9;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.stat-summary-value {
    font-size: 0.95rem;
    color: #fff;
    font-weight: 700;
    line-height: 1.1;
}

.stat-summary-value.positive {
    color: #00ff88;
}

.stat-summary-value.negative {
    color: #ff4444;
}

/* Control Panel */
.control-panel {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    padding-bottom: 60px;
    margin-bottom: 30px;
    position: relative;
    min-height: 120px;
}

.panel-title {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #00d4ff;
}

#datosHist {
    display: grid;
    gap: 14px;
}

.datos-hist-layout {
    display: grid;
    grid-template-columns: minmax(260px, 0.95fr) minmax(320px, 1.25fr);
    gap: 12px;
}

.datos-hist-left,
.datos-hist-right {
    display: grid;
    gap: 8px;
}

.datos-hist-hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.datos-hist-metric {
    padding: 10px 12px;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.datos-hist-metric.accent-cyan {
    border-color: rgba(0, 212, 255, 0.28);
}

.datos-hist-metric.accent-green {
    border-color: rgba(0, 255, 136, 0.22);
}

.datos-hist-metric.accent-amber {
    border-color: rgba(255, 193, 7, 0.24);
}

.datos-hist-metric.accent-red {
    border-color: rgba(255, 68, 68, 0.24);
}

.datos-hist-metric-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #9fb4cf;
    margin-bottom: 6px;
}

.datos-hist-metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.datos-hist-metric-large .datos-hist-metric-value {
    font-size: 1.5rem;
}

.datos-hist-ranges {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
}

.datos-hist-range-card {
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.datos-hist-range-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #d8e9ff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.datos-hist-range-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.datos-hist-range-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.datos-hist-range-label {
    font-size: 0.68rem;
    color: #9fb4cf;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.datos-hist-range-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.datos-hist-range-value.positive {
    color: #00ff88;
}

.datos-hist-range-value.negative {
    color: #ff7777;
}

.datos-hist-secondary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}

.datos-hist-secondary-item {
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.datos-hist-secondary-label {
    font-size: 0.68rem;
    color: #9fb4cf;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.datos-hist-secondary-value {
    font-size: 0.9rem;
    color: #fff;
    font-weight: 700;
    line-height: 1.2;
    word-break: break-word;
}

.datos-hist-empty {
    padding: 14px;
    color: #aaa;
    text-align: center;
}

.datos-hist-horizontal {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.datos-hist-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}

.datos-hist-cyan {
    color: #00d4ff;
}

.datos-hist-green {
    color: #00ff88;
}

.datos-hist-red {
    color: #ff7777;
}

@media (max-width: 900px) {
    .datos-hist-layout {
        grid-template-columns: 1fr;
    }
}

#posicionCurso,
#posicionEsperando,
#posicionCurso-ton,
#posicionEsperando-ton,
#posicionCurso-sol,
#posicionEsperando-sol,
#ultimaOperacion {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 2px;
    align-items: center;
}


.posicion-field {
    background: transparent;
    border: none;
    padding: 2px 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
}

.posicion-field.wide-field {
    min-width: 110px;
}

.posicion-field:not(:last-child) {
    border-right: 1px solid rgba(255, 255, 255, 0.12);
    padding-right: 4px;
    margin-right: 4px;
}

.posicion-label {
    color: #aaa;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.posicion-value {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    word-break: break-word;
}

.posicion-badge {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.posicion-badge.open {
    background: rgba(255, 68, 68, 0.15);
    color: #ff7777;
    border: 1px solid rgba(255, 68, 68, 0.25);
}

.posicion-badge.closed {
    background: rgba(0, 255, 136, 0.15);
    color: #88ffb3;
    border: 1px solid rgba(0, 255, 136, 0.25);
}

.posicion-badge.buy {
    background: rgba(0, 255, 136, 0.15);
    color: #88ffb3;
    border: 1px solid rgba(0, 255, 136, 0.25);
}

.posicion-badge.sell {
    background: rgba(255, 68, 68, 0.15);
    color: #ff7777;
    border: 1px solid rgba(255, 68, 68, 0.25);
}

.posicion-value.positive {
    color: #00ff88;
}

.posicion-value.negative {
    color: #ff4444;
}

.switch-group {
    display: flex;
    gap: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    transition: 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.switch:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.switch input {
    width: 44px;
    height: 22px;
    appearance: none;
    background: #444;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.switch input:checked {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.switch input::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.switch input:checked::before {
    left: 24px;
    background: white;
}

/* Mode indicator */
.mode-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    display: inline-block;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.mode-sim {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.2), rgba(255, 152, 0, 0.1));
    border: 1px solid rgba(255, 152, 0, 0.4);
    color: #ff9800;
}

.mode-real {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.2), rgba(244, 67, 54, 0.1));
    border: 1px solid rgba(244, 67, 54, 0.4);
    color: #f44336;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 768px) {
    .charts-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Tables */
.table-container {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

th {
    color: #00d4ff;
    font-weight: 600;
}

.buy {
    color: #00ff88;
}

.sell {
    color: #ff4444;
}

button {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    margin: 5px;
}

button:hover {
    opacity: 0.8;
}

.refresh-btn {
    background: #333;
    color: white;
    margin-bottom: 20px;
}

.status-online {
    color: #00ff88;
    animation: pulse 2s infinite;
}

.status-offline {
    color: #ff4444;
    animation: none;
}

.tiempo-viva-alerta {
    color: #ff9800;
    animation: pulse-slow 3.5s infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-slow {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.45;
    }
}

.timestamp {
    font-size: 0.8rem;
    color: #888;
}

/* Tabs */
.tabs-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin: 0 0 20px 0;
}

.tab-button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    flex: 1 1 auto;
    min-width: 80px;
    max-width: 120px;
    text-align: center;
    font-size: 0.9rem;
}

.tab-button.active {
    background: linear-gradient(90deg, #00d4ff, #00ff88);
    border-color: rgba(0, 212, 255, 0.6);
    color: #0b1020;
}

@media (max-width: 768px) {
    .tabs-container {
        gap: 8px;
    }

    .tab-button {
        padding: 8px 12px;
        font-size: 0.8rem;
        min-width: 60px;
        max-width: 100px;
    }
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.tab-empty {
    padding: 30px;
    color: #aaa;
    text-align: center;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 15px;
    border: 1px dashed rgba(255, 255, 255, 0.18);
    margin-bottom: 30px;
}

/* RSI cerca de compra - parpadeo naranja */
.rsi-cerca-compra {
    color: #ff9800 !important;
    animation: blink-orange 1s infinite;
    font-weight: bold;
}

@keyframes blink-orange {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Stats Compact Grid */
.stat-card {
    margin-bottom: 30px;
}

.stats-compact-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-compact-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-compact-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-compact-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
}

.stat-compact-inline {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 1.1rem;
}

.stat-compact-symbol {
    font-size: 0.9rem;
    color: #888;
}

.stat-compact-symbol-euro {
    color: #00d4ff;
}

.stat-compact-value-euro {
    color: #00d4ff;
}

.stat-compact-separator {
    color: #555;
    margin: 0 5px;
}

.stat-compact-detail {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.8rem;
    color: #aaa;
}

.stat-compact-detail span {
    color: #666;
}

.stat-compact-detail strong {
    color: #fff;
}

/* Panel de Control - Diseño Ultra Compacto */
.control-ultra-compact {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-ultra-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.control-ultra-config {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
}

.control-ultra-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}

.control-ultra-label {
    font-size: 0.65rem;
    color: #888;
    font-weight: 500;
}

.control-ultra-config input {
    flex: 1;
    padding: 5px 6px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.control-ultra-config input:focus {
    outline: none;
    border-color: #00d4ff;
    background: rgba(255, 255, 255, 0.12);
}

.control-ultra-save {
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    background: linear-gradient(135deg, #00d4ff, #00a8cc);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-ultra-save:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 212, 255, 0.3);
}

.control-ultra-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.control-ultra-btn {
    padding: 6px 10px;
    border-radius: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-ultra-btn:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.12);
}

.control-ultra-btn-success {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(0, 255, 136, 0.08));
    border: 1px solid rgba(0, 255, 136, 0.3);
}

.control-ultra-btn-success:hover {
    background: linear-gradient(135deg, rgba(0, 255, 136, 0.25), rgba(0, 255, 136, 0.15));
}

.control-ultra-btn-info {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.15), rgba(0, 212, 255, 0.08));
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.control-ultra-btn-info:hover {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.25), rgba(0, 212, 255, 0.15));
}

.control-ultra-btn-warning {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 193, 7, 0.08));
    border: 1px solid rgba(255, 193, 7, 0.3);
}

.control-ultra-btn-warning:hover {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.25), rgba(255, 193, 7, 0.15));
}

.control-ultra-btn-orange {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.15), rgba(255, 152, 0, 0.08));
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.control-ultra-btn-orange:hover {
    background: linear-gradient(135deg, rgba(255, 152, 0, 0.25), rgba(255, 152, 0, 0.15));
}

/* Monitor Styles */
.monitor-form {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.monitor-form h3 {
    margin: 0 0 10px 0;
    color: #00d4ff;
    font-size: 1rem;
}

.monitor-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.monitor-table {
    width: 100%;
    border-collapse: collapse;
}

.monitor-info {
    padding: 10px 15px;
    background: rgba(0, 212, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 15px;
    color: #00d4ff;
    font-size: 0.9rem;
    border: 1px solid rgba(0, 212, 255, 0.2);
}

.monitor-header {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 0.8fr 0.6fr 0.6fr 1fr 1fr 2fr;
    gap: 10px;
    padding: 10px;
    background: rgba(0, 212, 255, 0.1);
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    color: #00d4ff;
    font-size: 0.85rem;
}

.monitor-row {
    display: grid;
    grid-template-columns: 0.5fr 0.5fr 0.8fr 0.6fr 0.6fr 1fr 1fr 2fr;
    gap: 10px;
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    align-items: center;
    font-size: 0.85rem;
}

.monitor-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.monitor-row:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.target-compra-active {
    animation: blink-red 1s ease-in-out infinite;
    color: #ff4444;
}

@keyframes blink-red {
    0%, 100% {
        color: #ff4444;
        text-shadow: 0 0 5px rgba(255, 68, 68, 0.5);
    }
    50% {
        color: #ff8888;
        text-shadow: 0 0 10px rgba(255, 136, 136, 0.8);
    }
}

@media (max-width: 768px) {
    .monitor-form-row {
        flex-direction: column;
        gap: 8px;
    }

    .monitor-form-row input,
    .monitor-form-row button {
        width: 100%;
    }

    .monitor-info {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .monitor-header {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
        padding: 8px;
        font-size: 0.7rem;
    }

    .monitor-row {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
        padding: 8px;
        font-size: 0.7rem;
    }

    .monitor-row > div:nth-child(n+3) {
        grid-column: span 2;
    }

    .monitor-row input {
        width: 100%;
        font-size: 0.7rem;
        padding: 4px;
    }

    .monitor-row button {
        padding: 4px 8px;
        font-size: 0.7rem;
    }
}

