body {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    margin: 0;
    padding: 0;
}

.login-container {
    max-width: 350px;
    margin: 100px auto;
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
@media (max-width: 768px) {
    .login-container {
        margin: 60px 20px;
        max-width: none;
    }
}

.login-container h2 {
    text-align: center;
    color: #2c3e50;
}

.login-container label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

.login-container input {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    box-sizing: border-box;
}

.login-container button {
    margin-top: 20px;
    width: 100%;
    padding: 10px;
    background-color: #2c3e50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.login-container button:hover {
    background-color: #1a252f;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 220px;
    background-color: #2c3e50;
    color: white;
    transition: width 0.3s ease;
    z-index: 100;
    overflow-x: hidden;
    overflow-y: auto;
}

.sidebar.closed {
    width: 60px;
}
/* Aplica TODO el estado "cerrado" desde el primer instante, antes de que cargue el JS, para evitar el parpadeo */
.sidebar-precargado-cerrado .sidebar {
    width: 60px;
}

.sidebar-precargado-cerrado .main-content {
    margin-left: 60px;
}

.sidebar-precargado-cerrado .toggle-btn {
    left: 75px;
}

.sidebar-precargado-cerrado .sidebar-header {
    justify-content: center;
    padding: 15px 5px;
}

.sidebar-precargado-cerrado .sidebar-brand {
    display: none;
}

.sidebar-precargado-cerrado .sidebar-user {
    display: none;
}

.sidebar-precargado-cerrado .sidebar-links a {
    padding: 15px;
    justify-content: center;
}

.sidebar-precargado-cerrado .sidebar-links a .link-text {
    display: none;
}

.sidebar-precargado-cerrado .sidebar-logo-full {
    display: none;
}

.sidebar-precargado-cerrado .sidebar-logo-icono {
    display: block;
}

/* Desactiva las animaciones SOLO durante la carga inicial, para que el cambio no se vea "deslizando" */
.sidebar-precargado-cerrado .sidebar,
.sidebar-precargado-cerrado .main-content,
.sidebar-precargado-cerrado .toggle-btn,
.sidebar-precargado-cerrado .sidebar-links a {
    transition: none !important;
}
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    border-bottom: 1px solid #3d5166;
}

.sidebar-brand {
    font-size: 20px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.closed .sidebar-header {
    justify-content: center;
    padding: 15px 5px;
}

.sidebar.closed .sidebar-brand {
    display: none;
}

.sidebar-user {
    padding: 10px 20px;
    font-style: italic;
    font-size: 14px;
    color: #bbb;
    border-bottom: 1px solid #3d5166;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar.closed .sidebar-user {
    display: none;
}

.sidebar-links {
    display: flex;
    flex-direction: column;
}

.sidebar-links a {
    color: white;
    text-decoration: none;
    padding: 15px 20px;
    border-bottom: 1px solid #3d5166;
    white-space: nowrap;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-links a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar-links a:hover {
    background-color: #34495e;
}

.sidebar.closed .sidebar-links a {
    padding: 15px;
    justify-content: center;
}

.sidebar.closed .sidebar-links a .link-text {
    display: none;
}

/* Botón para abrir/cerrar */
.toggle-btn {
    background-color: transparent;
    color: white;
    border: none;
    font-size: 20px;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}

.toggle-btn:hover {
    background-color: #34495e;
}

/* Contenido principal */
.main-content {
    margin-left: 220px;
    padding: 30px;
    transition: margin-left 0.3s ease;
}
.main-content.expanded {
    margin-left: 60px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

table th, table td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}
/* Celda de acciones: iconos compactos en una sola línea; si no entran todos, la tabla entera scrollea horizontal (ya lo maneja .tabla-scroll-container) */
td:has(.btn-icon) {
    white-space: nowrap;
    padding: 8px 10px;
}

table th {
    background-color: #34495e;
    color: white;
}

.btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: #2c3e50;
    color: white;
    text-decoration: none;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 14px;
}

.btn:hover {
    background-color: #1a252f;
}

.btn-danger {
    background-color: #c0392b;
}

.btn-danger:hover {
    background-color: #922b21;
}

.form-box {
    background: white;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    max-width: 500px;
}

.form-box label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
}

.form-box input, .form-box select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    box-sizing: border-box;
}

.top-actions {
    margin-bottom: 15px;
}

/* Semáforos */
.semaforo-select {
    border: none;
    border-radius: 12px;
    padding: 4px 10px;
    color: white;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
}

.semaforo-dot {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.fase-pendiente   { background-color: #b0b0b0; }
.fase-en_proceso  { background-color: #e67e22; }
.fase-completado  { background-color: #27ae60; }
.fase-retrasado   { background-color: #c0392b; }

/* Panel superior (crear proyecto) */
.panel-box {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.panel-box h3 {
    margin-top: 0;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.form-inline .field {
    display: flex;
    flex-direction: column;
    min-width: 180px;
}

.form-inline label {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 14px;
}

.form-inline select,
.form-inline input {
    padding: 8px;
}

.filtros-box {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.filtros-box input {
    padding: 8px;
    flex: 1;
}

table.tabla-proyectos th, table.tabla-proyectos td {
    text-align: center;
}

table.tabla-proyectos td:nth-child(1),
table.tabla-proyectos td:nth-child(2),
table.tabla-proyectos td:nth-child(3) {
    text-align: left;
}

.semaforo-widget {
    position: relative;
    display: inline-block;
}

.semaforo-toggle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #ccc;
    cursor: pointer;
    padding: 0;
}

.semaforo-menu {
    display: none;
    position: fixed;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
    z-index: 500;
    min-width: 150px;
    padding: 6px 0;
}

.semaforo-menu.abierto {
    display: block;
}

.semaforo-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
}

.semaforo-option:hover {
    background-color: #f0f0f0;
}

.split-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.split-form {
    flex: 0 0 340px;
}

@media (max-width: 768px) {
    .split-layout {
        flex-direction: column;
    }

    .split-form {
        flex: 1 1 100%;
        width: 100%;
    }

    .split-table {
        width: 100%;
    }

    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-inline .field {
        min-width: 100%;
    }

    .fila-boton-filtro {
        flex-direction: column;
        align-items: stretch;
    }

    .fila-boton-filtro select,
    .fila-boton-filtro .btn,
    .fila-boton-filtro .form-toggle-btn {
        width: 100%;
    }

    .btn-icon {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .btn {
        padding: 10px 16px;
    }
}

.split-form .form-box {
    width: 100%;
    box-sizing: border-box;
}

.split-table {
    flex: 1;
    min-width: 320px;
    overflow-x: auto;
}
.tabla-scroll-container {
    max-height: 420px; /* aprox. 8 filas + encabezado */
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 4px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
}

.tabla-scroll-container table {
    box-shadow: none; /* ya lo tiene el contenedor, evitamos doble sombra */
}

.tabla-scroll-container thead th,
.tabla-scroll-container tr:first-child th {
    position: sticky;
    top: 0;
    z-index: 10;
}

.fila-grupo-proyecto td {
    background-color: #ecf0f1;
    font-weight: bold;
    padding: 10px 15px;
    border-top: 2px solid #bdc3c7;
}

.grupo-total {
    float: right;
    color: #2c3e50;
    font-weight: normal;
    font-size: 13px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: white;
    background-color: #2c3e50;
    font-size: 10px;
    text-decoration: none;
    margin: 1px;
    flex-shrink: 0;
}

.btn-icon:hover {
    background-color: #1a252f;
}

.btn-icon.btn-danger {
    background-color: #c0392b;
}

.btn-icon.btn-danger:hover {
    background-color: #922b21;
}

.btn-icon.btn-success {
    background-color: #27ae60;
}

.btn-icon.btn-success:hover {
    background-color: #1e8449;
}

.inline-form {
    display: inline-block;
    margin: 0;
}
/* Logo en el login */
.login-logo {
    display: block;
    max-width: 260px;
    width: 100%;
    height: auto;
    margin: 0 auto 10px auto;
}

/* Logo en el sidebar */
.sidebar-logo-full {
    max-width: 150px;
    width: 100%;
    height: auto;
    display: block;
}

.sidebar-logo-icono {
    display: none;
    font-size: 22px;
    font-weight: bold;
    color: white;
}

.sidebar.closed .sidebar-logo-full {
    display: none;
}

.sidebar.closed .sidebar-logo-icono {
    display: block;
}

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 14px 20px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: toastEntrada 0.3s ease;
}

.toast.toast-oculto {
    animation: toastSalida 0.3s ease forwards;
}

.toast-success {
    background-color: #27ae60;
}

.toast-error {
    background-color: #c0392b;
}

.toast i {
    font-size: 18px;
}

@keyframes toastEntrada {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes toastSalida {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

.pago-select {
    display: block;
    margin-top: 4px;
    border: none;
    border-radius: 4px;
    padding: 3px 4px;
    font-size: 11px;
    color: white;
    cursor: pointer;
    width: 100%;
}

.pago-badge {
    display: inline-block;
    margin-top: 4px;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    color: white;
}

.pago-pendiente { background-color: #b0b0b0; }
.pago-facturado { background-color: #2980b9; }
.pago-pagado    { background-color: #27ae60; }
.pago-atrasado  { background-color: #e67e22; }


.info-dos-columnas {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
}

.info-columna-divisor {
    border-left: 1px solid #ddd;
    padding-left: 30px;
}

@media (max-width: 700px) {
    .info-dos-columnas {
        grid-template-columns: 1fr;
    }
    .info-columna-divisor {
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #ddd;
        padding-top: 15px;
    }
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    text-align: center;
}

.kpi-card i {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 8px;
}

.kpi-valor {
    font-size: 26px;
    font-weight: bold;
    color: #2c3e50;
}

.kpi-label {
    font-size: 13px;
    color: #666;
    margin-top: 5px;
}

.dashboard-dos-columnas {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 800px) {
    .dashboard-dos-columnas {
        grid-template-columns: 1fr;
    }
}

.chart-box {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
}
/* Badge de contador sobre los botones-icono */
.btn-icon {
    position: relative;
}

.badge-contador {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #c0392b;
    color: white;
    border-radius: 10px;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    padding: 0 3px;
}

/* Chat de comentarios */
.chat-nota-fija {
    background: #fff8e1;
    border-left: 4px solid #f1c40f;
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.chat-box {
    background: white;
    border-radius: 8px;
    box-shadow: 0 0 5px rgba(0,0,0,0.1);
    padding: 20px;
}

.chat-mensajes {
    max-height: 420px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    background: #f7f9fa;
    border-radius: 6px;
    margin-bottom: 15px;
}

.chat-msg {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    align-self: flex-start;
}

.chat-msg.propio {
    align-self: flex-end;
    background: #dff0e5;
}

.chat-msg-meta {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.chat-msg-texto {
    font-size: 14px;
    word-wrap: break-word;
}

.etiqueta-chip {
    color: white;
    border-radius: 10px;
    padding: 1px 8px;
    font-size: 10px;
}

.etiqueta-observacion { background-color: #2980b9; }
.etiqueta-pendiente   { background-color: #e67e22; }
.etiqueta-resuelto    { background-color: #27ae60; }

.chat-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.chat-form textarea {
    flex: 1;
    min-width: 220px;
    padding: 8px;
    box-sizing: border-box;
}

.chat-form select {
    padding: 8px;
}

/* Tablas un poco más compactas en general */
table {
    font-size: 13px;
}

table th, table td {
    padding: 8px 10px;
}

/* Formulario colapsable dentro de split-layout */
.split-form.collapsed {
    display: none;
}

.form-toggle-btn {
    background: none;
    border: 1px solid #2c3e50;
    color: #2c3e50;
    cursor: pointer;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    margin-bottom: 15px;
}

.form-toggle-btn:hover {
    background-color: #2c3e50;
    color: white;
}
.titulo-con-boton {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.titulo-con-boton h2 {
    margin: 0;
}
.fila-boton-filtro {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 0;
    margin-bottom: 12px;
}

.fila-boton-filtro select {
    padding: 8px;
    min-width: 220px;
}
/* Recorta el espacio entre el título del módulo y lo que viene después */
.container h2:first-child,
.main-content > h2:first-of-type {
    margin-top: 0;
    margin-bottom: 10px;
}


.top-actions {
    margin-bottom: 12px;
}

@media (max-width: 768px) {
    /* El sidebar pasa a ser un overlay que se desliza por encima, no que empuja */
    .sidebar {
        position: fixed;
        z-index: 300;
        width: 220px;
        left: -220px;
        transition: left 0.3s ease;
    }
    /* El botón ☰ vive dentro del sidebar, pero en celular necesita quedar SIEMPRE visible, aunque el sidebar esté oculto fuera de la pantalla */
    .toggle-btn {
        position: fixed !important;
        top: 15px;
        left: 15px !important;
        z-index: 320;
        background-color: #2c3e50;
        width: 40px;
        height: 40px;
        border-radius: 6px;
    }

    .sidebar-header {
        justify-content: flex-end;
    }
    .sidebar.closed {
        left: -220px;
        width: 220px; /* en celular no usamos el modo "angosto con iconos", directamente se oculta del todo */
    }

    .sidebar.abierto-movil {
        left: 0;
    }

    .sidebar.abierto-movil .sidebar-brand,
    .sidebar.abierto-movil .sidebar-user,
    .sidebar.abierto-movil .link-text,
    .sidebar.abierto-movil .sidebar-logo-full {
        display: block;
    }

    .sidebar.abierto-movil .sidebar-logo-icono {
        display: none;
    }

    /* El contenido principal SIEMPRE ocupa todo el ancho en celular, el sidebar no le resta espacio */
    .main-content,
    .main-content.expanded {
        margin-left: 0;
        padding: 55px 15px 20px 15px;
    }

    .toggle-btn,
    .toggle-btn.closed {
        left: 15px;
    }

    /* Fondo oscuro detrás del sidebar cuando está abierto, para cerrar tocando afuera */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 250;
    }

    .sidebar-overlay.visible {
        display: block;
    }
}