:root {
    --brand-blue: #156082;
    --brand-green: #158274;
    --brand-green-hover: #106960;
    --accent-orange: #FF8338;
    --bg-page: #eef1f5;
    --text-dark: #333;
    --success: #28a745;
    --danger: #dc3545;
}

body {
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* --- HEADER PRINCIPAL --- */
.main-header {
    background-color: var(--brand-blue);
    height: 50px;
    padding: 0 15px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.header-content {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.logo-box {
    background: white;
    padding: 2px 5px;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: black;
    font-weight: bold;
    width: 50px;
    height: 35px;
}

.nav-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.nav-btn {
    background: white;
    border: none;
    color: black;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 2px;
}

.nav-btn:hover {
    background: #f0f0f0;
}

.action-btn-green,
.btn-create {
    background-color: var(--brand-green);
    color: white;
    border: none;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 3px;
    transition: 0.2s;
}

.action-btn-green:hover,
.btn-create:hover {
    background-color: var(--brand-green-hover);
}

.webhook-box {
    background-color: #0f4661;
    color: white;
    padding: 6px 10px;
    font-size: 0.8rem;
    border-radius: 3px;
    margin-left: auto;
}

/* --- LAYOUT --- */
.dex-container {
    padding: 5px;
    height: calc(100vh - 50px);
    overflow: hidden;
}

.main-layout {
    display: flex;
    gap: 5px;
    height: 100%;
}

/* Panel Izquierdo */
.left-panel {
    flex: 4;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow: hidden;
}

.top-half {
    flex: 3;
    min-height: 0;
}

.bottom-half {
    flex: 2;
    min-height: 0;
}

/* Panel Derecho (Dividido) */
.right-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 5px;
    overflow: hidden;
}

.right-top-half {
    flex: 6;
    min-height: 0;
}

/* Grafico mas alto */
.right-bottom-half {
    flex: 4;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* Panel P&L */

/* SECCIONES GENERICAS */
.dex-section {
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title-bar {
    background-color: var(--brand-blue);
    color: white;
    padding: 5px 10px;
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 2px solid var(--accent-orange);
    flex-shrink: 0;
}

/* --- ESTILOS NUEVO PANEL P&L --- */
.pnl-panel-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pnl-big-value {
    font-size: 2rem;
    font-weight: bold;
    text-align: left;
    line-height: 1;
}

.pnl-details-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: #555;
}

.pnl-row {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px dotted #ccc;
    padding-bottom: 2px;
}

.pnl-row span:last-child {
    font-weight: 600;
    color: var(--text-dark);
}

/* Barra Win Rate */
.win-rate-container {
    margin-top: auto;
    /* Empujar al fondo */
}

.win-rate-label {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 5px;
    color: var(--brand-blue);
}

.win-rate-bar-bg {
    height: 20px;
    background-color: var(--danger);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.win-rate-bar-fill {
    height: 100%;
    background-color: var(--success);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.win-rate-text {
    color: white;
    font-size: 0.8rem;
    font-weight: bold;
}

/* --- TABLAS (Sin Cambios Mayores) --- */
.table-container {
    flex: 1;
    overflow: auto;
    background: white;
}

.dex-bots-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    table-layout: auto;
}

.dex-bots-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--brand-blue);
    color: white;
}

.dex-bots-table th {
    padding: 6px 4px;
    text-align: center;
    font-weight: 600;
    white-space: nowrap;
    border-right: 1px dashed rgba(255, 255, 255, 0.3);
}

.dex-bots-table td {
    padding: 4px 4px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
    white-space: nowrap;
    text-align: center;
    color: #333;
    height: 30px;
}

.dex-bots-table tbody tr:hover {
    background-color: #f1f8ff;
    cursor: pointer;
}

.dex-bots-table tbody tr.selected {
    background-color: #e3f2fd !important;
    border-left: 3px solid var(--brand-blue);
}

.text-green {
    color: var(--success);
    font-weight: bold;
}

.text-red {
    color: var(--danger);
    font-weight: bold;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 2px;
    font-size: 0.9rem;
    opacity: 0.8;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.icon-blue {
    color: var(--brand-blue);
}

.icon-delete {
    color: var(--danger);
    background: rgba(220, 53, 69, 0.1);
    padding: 4px;
    border-radius: 3px;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.status-completed {
    background-color: var(--success);
    color: white;
    padding: 2px 6px;
    border-radius: 2px;
    font-weight: bold;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.table-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* --- WIDGET CONTAINER --- */
#bot-widget-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

.widget-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-style: italic;
    background: #fafafa;
}

/* --- MODAL (Sin Cambios) --- */
.modal.hidden {
    display: none;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    width: 400px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border-radius: 4px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.create-bot-title {
    background: white;
    padding: 15px;
    text-align: center;
    color: var(--brand-blue);
    font-weight: bold;
    border-bottom: 1px solid #ddd;
}

.modal-body {
    padding: 15px;
    overflow-y: auto;
}

.form-heading {
    color: var(--brand-blue);
    border-bottom: 1px solid #eee;
    margin-top: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
}

.form-subheading {
    background: #f8f9fa;
    padding: 5px;
    font-size: 0.8rem;
    border-left: 3px solid var(--brand-blue);
    margin: 10px 0;
}

.form-group {
    margin-bottom: 8px;
}

.form-group label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 2px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.85rem;
    box-sizing: border-box;
}

.btn-cancel {
    background: var(--danger);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
}

.form-buttons {
    padding: 10px;
    background: #f9f9f9;
    text-align: right;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.hidden-section {
    display: none;
}

/* --- ESTILOS GRÁFICO PNL (Agregado para feature/grafico-pnl) --- */

.chart-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    /* Pequeña separación entre botones */
}

.chart-period-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #a0a0a0;
    /* Gris suave */
    font-size: 0.7rem;
    cursor: pointer;
    padding: 2px 8px;
    /* Un poco más ancho para click fácil */
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s ease;
    text-transform: uppercase;
}

.chart-period-btn:hover {
    color: #333;
    background-color: #f0f0f0;
}

.chart-period-btn.active {
    background-color: #e3f2fd;
    /* Azul muy claro de fondo */
    color: #156082;
    /* Tu brand-blue */
    border-color: #bee3f8;
}

#pnl-chart-wrapper canvas {
    display: block;
    width: 100%;
    height: 100%;
}