:root {
    --bg-body: #f4f6f8;
    --bg-container: #fff;
    --text-main: #01060D;
    --text-muted: #666;
    --border-color: #ccd;
    --border-light: #dde;
    --accent-color: #0d6efd;
    --accent-hover: #0b5ed7;
    --card-bg: rgba(255, 255, 255, 0.95);
    --input-bg: #fff;
    --nav-bg: rgba(255, 255, 255, 0.8);
    --table-stripe: #f8f9fa;
    --panel-bg: #fff;
    --info-bg: #f8f9fa;
    --feed-bg: #f8f9fa;
    --bg-urgente: #ffe3e3;
    --bg-alta: #fff4e6;
    --bg-media: #fff9db;
    --bg-baja: #f4fce3;
    --text-table: #01060D;
    --font-weight-extreme: normal;
}

[data-theme="dark"] {
    --bg-body: #05070a;
    --bg-container: #090e1a;
    --text-main: #ffffff;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --border-light: #161e2e;
    --accent-color: #38bdf8;
    --accent-hover: #0ea5e9;
    --card-bg: rgba(5, 7, 10, 0.95);
    --input-bg: #05070a;
    --nav-bg: rgba(5, 7, 10, 0.9);
    --table-stripe: #090e1a;
    --panel-bg: #090e1a;
    --info-bg: #05070a;
    --feed-bg: #05070a;
    --bg-urgente: #1a0808;
    --bg-alta: #080c1a;
    --bg-media: #07090f;
    --bg-baja: #05070a;
    --text-table: #ffffff;
    --font-weight-extreme: bold;
}

body { font-family: Arial, sans-serif; background: var(--bg-body); margin: 0; color: var(--text-main); font-size: 13px; transition: background 0.3s, color 0.3s; }
.container { max-width: 1600px; margin: 10px auto; background: var(--bg-container); padding: 20px; border-radius: 8px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.topbar { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; font-size: 12px; }
form { display: grid; gap: 10px; margin-bottom: 20px; }
input, textarea, select, button { padding: 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 12px; background: var(--input-bg); color: var(--text-main); }
button { background: var(--accent-color); color: #fff; cursor: pointer; font-weight: bold; border: none; }
table { width: 100%; border-collapse: collapse; color: var(--text-table) !important; }
th, td { border: 1px solid var(--border-light); padding: 8px; font-size: 11px; font-weight: var(--font-weight-extreme); color: var(--text-table) !important; }
.btn-bitacora { background: var(--accent-color); color: #fff; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; margin-right: 4px; }
.btn-edit { background: #ffc107; color: #000; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; font-size: 11px; }
.btn-bitacora:hover { background: var(--accent-hover); }
.btn-edit:hover { background: #e0a800; }
.kpis { display: grid; grid-template-columns: repeat(6,1fr); gap: 10px; margin-bottom: 20px; }
.kpis > div { background: var(--info-bg); padding: 10px; border-radius: 6px; font-weight: 700; font-size: 12px; text-align: center; border: 1px solid var(--border-light); }

/* Login Styles */
.login-body {
    background: linear-gradient(135deg, #0d6efd 0%, #00d4ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    margin: 0;
}

.login-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 320px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-light);
}

.login-card h2 {
    margin-top: 0;
    color: var(--accent-color);
    text-align: center;
    font-weight: 800;
    letter-spacing: -1px;
    font-size: 18px;
}

#msg {
    margin-top: 10px;
    padding: 6px;
    border-radius: 4px;
    font-size: 10px;
    text-align: center;
    min-height: 15px;
}

#msg.error { background: #fff5f5; color: #e03131; border: 1px solid #ffa8a8; }
#msg.success { background: #f4fce3; color: #2f9e44; border: 1px solid #b2f2bb; }

.login-card button {
    width: 100%;
    text-transform: uppercase;
    transition: transform 0.2s, background 0.2s;
}

.login-card button:hover:not(:disabled) { background: #0b5ed7; transform: translateY(-1px); }
.login-card button:disabled { opacity: 0.7; cursor: not-allowed; }

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

.modal-content {
    background: var(--bg-container);
    padding: 1.5rem;
    border-radius: 10px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    position: relative;
    animation: slideUp 0.3s ease-out;
    border: 1px solid var(--border-light);
    color: var(--text-main);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.modal-header h2 { margin: 0; color: var(--accent-color); font-size: 1.2rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #888;
}

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

.btn-new {
    background: #198754;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    font-size: 10px;
}

.btn-new:hover { background: #157347; }

/* Dashboard Layout */
.main-layout {
    margin-top: 15px;
}

.panel-left {
    width: 100%;
}

/* Drawer Bitácora */
.drawer-overlay {
    display: none;
    position: fixed;
    top: 54px; left: 0; width: 100%; height: calc(100vh - 54px);
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(2px);
    z-index: 998;
    animation: fadeIn 0.2s;
}

.panel-right {
    display: none; 
    position: fixed;
    right: -800px; 
    top: 54px;
    width: 700px;
    background: var(--panel-bg);
    height: calc(100vh - 54px);
    z-index: 999;
    box-shadow: -5px 0 25px rgba(0,0,0,0.1);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    border-left: 1px solid var(--border-light);
    color: var(--text-main);
}

.panel-right.drawer-open {
    right: 0;
}

.bitacora-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.bitacora-body {
    display: flex;
    gap: 20px;
    flex: 1;
    overflow: hidden;
}

.bitacora-info {
    position: relative;
    flex: 0 0 280px;
    background: var(--info-bg);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-light);
    overflow-y: auto;
    max-height: 100%;
}

.btn-edit-mini {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #e7f1ff;
    color: #0d6efd;
    border: 1px solid #0d6efd;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 11px;
}

.btn-edit-mini:hover {
    background: #0d6efd;
    color: #fff;
}

.bitacora-info h4 {
    margin: 0 0 15px 0;
    font-size: 17px;
    color: var(--accent-color);
    text-transform: uppercase;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 5px;
}

.info-field {
    margin-bottom: 12px;
}

.info-label {
    display: block;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.info-value {
    display: block;
    font-size: 13px;
    color: var(--text-main);
    font-weight: bold;
}

.info-desc {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-light);
    color: var(--text-main);
    font-weight: var(--font-weight-extreme);
}

.priority-badge { display:inline-block; padding:2px 6px; border-radius:4px; font-weight:bold; font-size:9px; }
.desc-text { font-size:11px; margin-top:5px; font-weight: var(--font-weight-extreme); }

.bitacora-feed {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-right: 5px;
}

.close-drawer {
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: var(--text-muted);
}

.close-drawer:hover { color: #333; }
.feed-item {
    padding: 10px;
    border-left: 3px solid var(--border-color);
    margin-bottom: 12px;
    background: var(--feed-bg);
    border-radius: 0 6px 6px 0;
    font-size: 12px;
    transition: transform 0.2s;
    color: var(--text-main);
    font-weight: bold;
}

.feed-item:hover { transform: translateX(3px); }
.feed-item.new { border-left-color: #198754; background: #f4fce3; }
.feed-item .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; display: flex; justify-content: space-between; }
.feed-item .user { font-weight: bold; color: var(--accent-color); }
.feed-item .comment { margin: 4px 0; line-height: 1.3; color: var(--text-main); font-weight: bold; }
.feed-item .badge { display: inline-block; padding: 2px 4px; background: #e9ecef; border-radius: 3px; font-size: 8px; }

/* Hilight active row */
tr.active-row { background-color: #eef4ff !important; outline: 2px solid #0d6efd; outline-offset: -2px; }
#bitacora-vacia { text-align: center; color: #999; padding: 30px 15px; font-style: italic; font-size: 10px; }

/* Dashboard Charts */
.charts-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.charts-container canvas {
    background: var(--bg-container);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    max-height: 250px;
}

.filtros {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.filtros label { font-size: 11px; font-weight: bold; color: #666; }

/* Navigation Styles */
.nav-main {
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 1100;
    padding: 0.5rem 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
}

.nav-brand {
    font-size: 17px;
    font-weight: 800;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 15px;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10px;
    transition: all 0.2s ease;
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a:hover {
    color: var(--accent-color);
    background: rgba(13, 110, 253, 0.05);
    transform: translateY(-1px);
}

.nav-links a.active {
    color: var(--accent-color);
    background: rgba(13, 110, 253, 0.1);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-name {
    font-weight: 600;
    color: var(--text-main);
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-logout {
    color: #dc3545;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.btn-logout:hover {
    background: #fff5f5;
    color: #e03131;
}

.btn-theme {
    background: transparent;
    border: none;
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-theme:hover {
    background: rgba(13, 110, 253, 0.1);
    color: var(--accent-color);
}

/* Escala de Colores por Prioridad */
.priority-urgente { background-color: var(--bg-urgente) !important; border-left: 5px solid #ff6b6b; }
.priority-alta { background-color: var(--bg-alta) !important; border-left: 5px solid #ffa94d; }
.priority-media { background-color: var(--bg-media) !important; border-left: 5px solid #ffd43b; }
.priority-baja { background-color: var(--bg-baja) !important; border-left: 5px solid #a9e34b; }

.priority-urgente:hover { filter: brightness(1.1) !important; }
.priority-alta:hover { filter: brightness(1.1) !important; }
.priority-media:hover { filter: brightness(1.1) !important; }
.priority-baja:hover { filter: brightness(1.1) !important; }
/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }

    .nav-container {
        padding: 4px 10px;
        flex-direction: column;
        gap: 6px;
    }
    
    .nav-brand {
        font-size: 15px;
        margin-bottom: 2px;
    }
    
    .nav-links {
        gap: 6px;
        width: 100%;
        justify-content: space-around;
        background: transparent;
        padding: 2px;
    }
    
    .nav-links a {
        font-size: 11px;
        padding: 4px 8px;
        background: #f1f3f5;
        border-radius: 6px;
    }

    .kpis {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        margin-bottom: 12px;
    }
    
    .kpis > div {
        padding: 6px;
        font-size: 10px;
    }

    /* Filtros Colapsables en Móvil */
    .header-filtros {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
    }

    .btn-toggle-filtros {
        background: #f1f3f5;
        color: #495057;
        border: 1px solid #dee2e6;
        font-size: 10px;
        padding: 5px 10px;
        border-radius: 6px;
        display: block; /* Visible solo en móvil via media query */
    }

    .filtros {
        display: none; /* Oculto por defecto en móvil */
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 10px;
        background: #f8f9fa;
        border-radius: 8px;
        margin-bottom: 15px;
    }
    
    .filtros.show {
        display: grid;
    }

    .filtros input, .filtros select {
        padding: 6px;
        font-size: 11px;
    }
    
    .table-container {
        overflow-x: hidden;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    /* Tarjetas más densas */
    tr {
        background: var(--bg-container);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 10px;
        padding: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        border-left: 5px solid var(--accent-color);
        color: var(--text-main);
    }

    td {
        border: none;
        position: relative;
        padding-left: 40% !important;
        text-align: right;
        min-height: 24px;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        border-bottom: 1px solid var(--border-light);
        font-size: 11px;
        color: var(--text-main);
    }

    td:last-child {
        border-bottom: none;
    }

    td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 35%;
        text-align: left;
        font-weight: 800;
        font-size: 7px;
        color: #6c757d;
        text-transform: uppercase;
    }

    .td-acciones {
        justify-content: center !important;
        padding: 8px !important;
        margin-top: 8px;
        background: var(--info-bg);
        border-radius: 4px;
        gap: 10px;
    }

    /* Prioridades en tarjetas */
    tr.priority-urgente { border-left-color: #ff6b6b; }
    tr.priority-alta { border-left-color: #ffa94d; }
    tr.priority-media { border-left-color: #ffd43b; }
    tr.priority-baja { border-left-color: #a9e34b; }

    .panel-right, .drawer-overlay, .modal-overlay {
        top: 85px;
        height: calc(100vh - 85px);
    }

    .modal-content {
        margin: 10px auto;
        max-height: 90vh;
    }

    /* Botón Flotante (FAB) para Nueva Tarea */
    .btn-new {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 15px rgba(0,0,0,0.3);
        z-index: 1050;
        font-size: 20px;
        line-height: 1;
        text-indent: -9999px;
    }

    .btn-new::after {
        content: '＋';
        text-indent: 0;
        display: block;
        position: absolute;
    }

    .main-layout {
        margin-top: 20px;
    }

    h2 {
        font-size: 14px;
        margin-bottom: 10px;
    }
}
