﻿* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family:
        Inter,
        Arial,
        Helvetica,
        sans-serif;
    background: #f5f7f8;
    color: #1f2937;
}

a {
    text-decoration: none;
    color: inherit;
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        linear-gradient(
            135deg,
            #eef5f1 0%,
            #f7f9fa 60%,
            #edf3f0 100%
        );
}

.login-wrapper {
    width: 100%;
    max-width: 430px;
}

.login-card {
    background: #ffffff;
    border-radius: 18px;
    padding: 42px;
    box-shadow:
        0 18px 50px rgba(0, 0, 0, 0.10);
}

.login-brand {
    text-align: center;
    margin-bottom: 34px;
}

.login-logo {
    width: 62px;
    height: 62px;
    margin: 0 auto 18px;
    border-radius: 16px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #245c43;
    color: white;

    font-size: 31px;
    font-weight: 700;
}

.login-brand h1 {
    margin: 0 0 8px;
    font-size: 28px;
}

.login-brand p {
    margin: 0;
    color: #6b7280;
    line-height: 1.5;
}

.login-error {
    margin-bottom: 20px;
    padding: 13px 15px;
    border-radius: 9px;

    background: #fef2f2;
    border: 1px solid #fecaca;

    color: #991b1b;
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 14px;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    height: 44px;

    padding: 0 12px;

    border:
        1px solid #d1d5db;

    border-radius: 8px;

    background: white;
    font-size: 15px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #39785b;

    box-shadow:
        0 0 0 3px
        rgba(57, 120, 91, 0.12);
}

.btn-primary {
    height: 46px;

    border: none;
    border-radius: 9px;

    background: #245c43;
    color: #ffffff;

    font-size: 15px;
    font-weight: 600;

    cursor: pointer;
}

.btn-primary:hover {
    background: #1d4c37;
}


/* =========================================================
   TOP BAR
   ========================================================= */

.topbar {
    height: 72px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 28px;

    background: #ffffff;

    border-bottom:
        1px solid #e5e7eb;

    position: sticky;
    top: 0;

    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    width: 42px;
    height: 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 11px;

    background: #245c43;
    color: white;

    font-size: 22px;
    font-weight: 700;
}

.brand-title {
    font-size: 18px;
    font-weight: 700;
}

.brand-subtitle {
    margin-top: 2px;

    font-size: 12px;
    color: #6b7280;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.company-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.company-selector label {
    font-size: 12px;
    color: #6b7280;
}

.company-selector select {
    min-width: 190px;

    height: 36px;

    padding: 0 10px;

    border:
        1px solid #d1d5db;

    border-radius: 7px;

    background: white;
}

.user-box {
    border-left:
        1px solid #e5e7eb;

    padding-left: 22px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
}

.user-role {
    margin-top: 2px;

    font-size: 11px;
    color: #6b7280;
}

.logout-link {
    font-size: 14px;
    color: #6b7280;
}

.logout-link:hover {
    color: #111827;
}


/* =========================================================
   APP
   ========================================================= */

.app-shell {
    display: flex;

    min-height:
        calc(100vh - 72px);
}

.sidebar {
    width: 235px;

    flex-shrink: 0;

    padding: 22px 14px;

    background: #ffffff;

    border-right:
        1px solid #e5e7eb;
}

.nav-section {
    margin:
        22px 12px
        8px;

    font-size: 10px;
    font-weight: 700;

    letter-spacing: 0.08em;

    color: #9ca3af;

    text-transform: uppercase;
}

.nav-item {
    display: block;

    padding:
        10px 12px;

    margin-bottom: 3px;

    border-radius: 7px;

    font-size: 14px;

    color: #4b5563;
}

.nav-item:hover {
    background: #f3f6f4;
    color: #245c43;
}

.nav-item.active {
    background: #e9f2ed;
    color: #245c43;

    font-weight: 600;
}

.main-content {
    flex: 1;

    min-width: 0;

    padding: 30px;
}


/* =========================================================
   DASHBOARD
   ========================================================= */

.page-header {
    display: flex;
    justify-content: space-between;

    margin-bottom: 26px;
}

.page-header h1 {
    margin: 0;

    font-size: 26px;
}

.page-header p {
    margin:
        6px 0 0;

    color: #6b7280;
}

.kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 24px;
}

.kpi-card {
    padding: 20px;

    border-radius: 12px;

    background: #ffffff;

    border:
        1px solid #e8eaed;
}

.kpi-label {
    margin-bottom: 10px;

    font-size: 12px;
    color: #6b7280;
}

.kpi-value {
    font-size: 25px;
    font-weight: 700;

    color: #111827;
}

.dashboard-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 20px;
}

.panel {
    min-height: 300px;

    background: #ffffff;

    border:
        1px solid #e8eaed;

    border-radius: 12px;
}

.panel-header {
    padding: 18px 20px;

    border-bottom:
        1px solid #edf0f2;

    font-size: 15px;
    font-weight: 600;
}

.empty-state {
    min-height: 230px;

    display: flex;
    flex-direction: column;

    align-items: center;
    justify-content: center;

    padding: 30px;

    text-align: center;

    color: #6b7280;
}

.empty-state span {
    display: block;

    margin-top: 9px;

    max-width: 310px;

    font-size: 13px;

    color: #9ca3af;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 1200px) {

    .kpi-grid {
        grid-template-columns:
            repeat(3, 1fr);
    }

}

@media (max-width: 800px) {

    .topbar {
        height: auto;

        padding: 14px 18px;

        flex-direction: column;
        align-items: flex-start;

        gap: 14px;
    }

    .topbar-actions {
        width: 100%;

        flex-wrap: wrap;

        gap: 12px;
    }

    .user-box {
        border-left: none;
        padding-left: 0;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        width: 100%;

        border-right: none;
        border-bottom:
            1px solid #e5e7eb;
    }

    .main-content {
        padding: 20px;
    }

    .kpi-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .dashboard-grid {
        grid-template-columns:
            1fr;
    }

}

@media (max-width: 500px) {

    .login-card {
        padding: 28px 22px;
    }

    .kpi-grid {
        grid-template-columns:
            1fr;
    }

}

.company-logo {
    width: 54px;
    height: 54px;

    object-fit: contain;

    background: #ffffff;

    border-radius: 10px;

    padding: 3px;
}

/* =========================================================
   TABLAS Y MANTENIMIENTOS
   ========================================================= */

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

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

.data-table th {
    padding: 13px 16px;

    text-align: left;

    background: #f8faf9;

    border-bottom:
        1px solid #e5e7eb;

    color: #6b7280;

    font-size: 12px;
    font-weight: 600;
}

.data-table td {
    padding: 14px 16px;

    border-bottom:
        1px solid #edf0f2;

    font-size: 14px;
}

.data-table tbody tr:hover {
    background: #fafcfb;
}

.actions-column {
    text-align: right !important;
    white-space: nowrap;
}

.inline-form {
    display: inline;
}

.badge {
    display: inline-block;

    padding: 5px 9px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 600;
}

.badge-active {
    background: #e8f5ed;
    color: #21633f;
}

.badge-inactive {
    background: #f3f4f6;
    color: #6b7280;
}

.btn-auto {
    width: auto;
    padding: 0 18px;
}

.btn-secondary,
.btn-small {
    border:
        1px solid #d1d5db;

    border-radius: 7px;

    background: #ffffff;

    color: #374151;

    cursor: pointer;
}

.btn-secondary {
    height: 42px;
    padding: 0 18px;
}

.btn-small {
    height: 32px;
    padding: 0 11px;

    font-size: 12px;
}

.btn-small:hover,
.btn-secondary:hover {
    background: #f5f7f8;
}

.btn-warning {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #9a3412;
}

.btn-success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.empty-table {
    padding: 40px !important;

    text-align: center;

    color: #9ca3af;
}


/* =========================================================
   ALERTAS
   ========================================================= */

.alert-success,
.alert-error {
    margin-bottom: 18px;

    padding: 13px 16px;

    border-radius: 8px;

    font-size: 14px;
}

.alert-success {
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}


/* =========================================================
   MODAL
   ========================================================= */

.modal-backdrop {
    position: fixed;

    inset: 0;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background:
        rgba(17, 24, 39, 0.40);

    z-index: 1000;
}

.modal-backdrop.show {
    display: flex;
}

.modal-card {
    width: 100%;
    max-width: 620px;

    background: white;

    border-radius: 14px;

    box-shadow:
        0 24px 60px
        rgba(0, 0, 0, 0.18);

    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 18px 22px;

    border-bottom:
        1px solid #e5e7eb;
}

.modal-header h2 {
    margin: 0;

    font-size: 18px;
}

.modal-close {
    width: 34px;
    height: 34px;

    border: none;

    border-radius: 7px;

    background: transparent;

    color: #6b7280;

    font-size: 24px;

    cursor: pointer;
}

.modal-close:hover {
    background: #f3f4f6;
}

.modal-body {
    padding: 22px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;

    padding: 16px 22px;

    background: #f9fafb;

    border-top:
        1px solid #e5e7eb;
}

.form-grid {
    display: grid;

    grid-template-columns:
        1fr 1fr;

    gap: 18px;
}


@media (max-width: 600px) {

    .form-grid {
        grid-template-columns:
            1fr;
    }

    .page-header {
        gap: 16px;
        flex-direction: column;
    }

}


.form-group-full {
    grid-column: 1 / -1;
}

.field-help {
    margin-top: 3px;
    font-size: 11px;
    line-height: 1.4;
    color: #9ca3af;
}


.production-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 220px));
    gap: 16px;
    margin-bottom: 20px;
}

.note-indicator {
    display: inline-block;
    margin-right: 6px;
    padding: 4px 7px;

    border-radius: 6px;

    background: #eef2ff;
    color: #4338ca;

    font-size: 11px;

    cursor: help;
}


@media (max-width: 600px) {

    .production-summary {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   LOGO EMPRESA - AJUSTE DE TAMAÑO
   ========================================================= */

.company-logo {
    width: 72px;
    height: 72px;

    object-fit: contain;

    flex-shrink: 0;

    background: transparent;

    border-radius: 8px;

    padding: 0;
}

.topbar {
    min-height: 92px;
    height: 92px;
}

.app-shell {
    min-height:
        calc(100vh - 92px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-title {
    font-size: 20px;
    font-weight: 700;
}

.brand-subtitle {
    margin-top: 3px;
    font-size: 13px;
}


@media (max-width: 800px) {

    .topbar {
        height: auto;
        min-height: 92px;
    }

    .company-logo {
        width: 64px;
        height: 64px;
    }

}


/* =========================================================
   PRODUCCIÓN V2
   ========================================================= */

.filter-panel {
    margin-bottom: 20px;

    padding: 18px 20px;

    background: #ffffff;

    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.filter-title {
    margin-bottom: 14px;

    font-size: 14px;
    font-weight: 700;
}

.production-filters {
    display: grid;

    grid-template-columns:
        repeat(6, minmax(130px, 1fr))
        auto;

    gap: 12px;

    align-items: end;
}

.filter-field {
    display: flex;
    flex-direction: column;

    gap: 6px;
}

.filter-field label {
    font-size: 11px;
    font-weight: 600;

    color: #6b7280;
}

.filter-field input,
.filter-field select {
    width: 100%;
    height: 39px;

    padding: 0 9px;

    background: #ffffff;

    border: 1px solid #d1d5db;
    border-radius: 7px;

    font-size: 13px;
}

.filter-field input:focus,
.filter-field select:focus {
    outline: none;

    border-color: #39785b;

    box-shadow:
        0 0 0 3px
        rgba(57, 120, 91, 0.10);
}

.filter-actions {
    display: flex;
    gap: 7px;

    align-items: center;
}

.filter-actions .btn-primary,
.filter-clear {
    height: 39px;

    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-clear {
    padding: 0 14px;
}


.production-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(6, minmax(0, 1fr));

    gap: 14px;

    margin-bottom: 20px;
}


.production-section {
    margin-bottom: 20px;
}


.panel-header {
    display: flex;

    justify-content: space-between;
    align-items: center;
}

.panel-header-note {
    font-size: 11px;
    font-weight: 400;

    color: #9ca3af;
}


.source-badge {
    display: inline-block;

    padding: 4px 7px;

    border-radius: 6px;

    background: #f3f4f6;

    color: #4b5563;

    font-size: 10px;
    font-weight: 700;
}

.source-test {
    background: #fff7ed;
    color: #9a3412;
}

.source-manual {
    background: #eff6ff;
    color: #1d4ed8;
}


@media (max-width: 1450px) {

    .production-filters {
        grid-template-columns:
            repeat(4, minmax(140px, 1fr));
    }

    .production-kpi-grid {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

}


@media (max-width: 850px) {

    .production-filters {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .production-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 520px) {

    .production-filters {
        grid-template-columns: 1fr;
    }

    .production-kpi-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   GRÁFICAS DE PRODUCCIÓN
   ========================================================= */

.production-chart-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;

    margin-bottom: 20px;
}

.chart-panel {
    min-width: 0;
}

.chart-container {
    position: relative;

    width: 100%;
    height: 330px;

    padding: 18px 20px 22px;
}


@media (max-width: 950px) {

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

}


/* =========================================================
   DASHBOARD V2
   ========================================================= */

.dashboard-secondary-kpis {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 250px));

    gap: 16px;

    margin-bottom: 20px;
}


@media (max-width: 700px) {

    .dashboard-secondary-kpis {
        grid-template-columns: 1fr;
    }

}


.badge-development {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-harvest {
    background: #ecfdf5;
    color: #166534;
}


/* =========================================================
   NÓMINA V2
   ========================================================= */

.payroll-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 14px;

    margin-bottom: 20px;
}

.kpi-development {
    color: #2563eb;
}

.kpi-harvest {
    color: #166534;
}

.kpi-subtext {
    margin-top: 4px;

    color: #9ca3af;

    font-size: 11px;
}


@media (max-width: 1200px) {

    .payroll-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 600px) {

    .payroll-kpi-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   COSTOS INTEGRALES
   ========================================================= */

.cost-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 14px;

    margin-bottom: 20px;
}

.cost-total-card {
    border:
        2px solid #245c43;

    background: #f5faf7;
}

.cost-total-card .kpi-value {
    color: #245c43;
}

.cost-breakdown-grid {
    display: grid;

    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;

    margin-bottom: 20px;
}

.cost-breakdown-body {
    padding: 18px 20px;
}

.cost-line {
    display: flex;

    align-items: center;
    justify-content: space-between;

    padding: 11px 0;

    border-bottom:
        1px solid #edf0f2;

    font-size: 14px;
}

.cost-line:last-child {
    border-bottom: none;
}

.cost-line-total {
    margin-top: 4px;

    padding-top: 15px;

    font-size: 15px;

    color: #245c43;
}


@media (max-width: 1200px) {

    .cost-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 750px) {

    .cost-kpi-grid,
    .cost-breakdown-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   COMPARATIVO SEMANAL
   ========================================================= */

.weekly-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 14px;

    margin-bottom: 20px;
}

.weekly-chart-grid {
    display: grid;

    grid-template-columns: 1fr;

    gap: 20px;

    margin-bottom: 20px;
}

.weekly-chart-large {
    height: 410px;
}


.metric-positive {
    color: #15803d;
}

.metric-negative {
    color: #dc2626;
}

.metric-warning {
    color: #d97706;
}


.compliance-badge {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    min-width: 70px;

    padding: 5px 8px;

    border-radius: 999px;

    font-size: 11px;
    font-weight: 700;
}


.compliance-good {
    background: #dcfce7;
    color: #166534;
}

.compliance-warning {
    background: #fef3c7;
    color: #92400e;
}

.compliance-low {
    background: #fee2e2;
    color: #991b1b;
}


@media (max-width: 1200px) {

    .weekly-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 600px) {

    .weekly-kpi-grid {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   CURVA DIARIA SEMANAL
   ========================================================= */

.weekly-curve-panel {
    margin-bottom: 20px;
}

.weekly-curve-summary {
    display: flex;

    gap: 24px;

    align-items: center;

    padding:
        12px 20px 0;

    font-size: 12px;

    color: #64748b;
}

.curve-dot {
    display: inline-block;

    width: 10px;
    height: 10px;

    margin-right: 6px;

    border-radius: 999px;
}

.curve-budget {
    background: #64748b;
}

.curve-real {
    background: #16a34a;
}


/* =========================================================
   ANÁLISIS POR PROYECTO
   ========================================================= */

.project-analysis-kpis {
    display: grid;
    grid-template-columns:
        repeat(6, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.project-analysis-chart-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.project-chart {
    height: 340px;
}


@media (max-width: 1300px) {

    .project-analysis-kpis {
        grid-template-columns:
            repeat(3, minmax(0, 1fr));
    }

}


@media (max-width: 900px) {

    .project-analysis-chart-grid {
        grid-template-columns: 1fr;
    }

}


@media (max-width: 700px) {

    .project-analysis-kpis {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 480px) {

    .project-analysis-kpis {
        grid-template-columns: 1fr;
    }

}


/* =========================================================
   REGISTROS CANCELADOS
   ========================================================= */

.row-cancelled {
    opacity: 0.58;
}

.row-cancelled td {
    text-decoration-color: rgba(0, 0, 0, 0.25);
}

.status-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.status-cancelled {
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
}


/* =========================================================
   FORMULARIOS DE EDICION DE OPERACIONES
   ========================================================= */

.operation-edit-panel {
    max-width: 1050px;
    margin: 0 auto;
    padding: 0;
    overflow: hidden;
}

.operation-edit-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #f8faf9;
}

.operation-edit-icon {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;

    flex-shrink: 0;

    border-radius: 10px;

    background: #e5f1ea;
    color: #17633f;

    font-size: 22px;
    font-weight: 700;
}

.operation-edit-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.operation-edit-subtitle {
    margin-top: 2px;
    font-size: 13px;
    color: #6b7280;
}


.operation-edit-panel .form-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    column-gap: 28px;
    row-gap: 20px;

    padding: 26px;
}


.operation-edit-panel .form-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
}


.operation-edit-panel .form-field label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}


.operation-edit-panel .form-field input,
.operation-edit-panel .form-field select,
.operation-edit-panel .form-field textarea {
    width: 100%;
    min-height: 40px;

    box-sizing: border-box;

    padding: 9px 11px;

    border: 1px solid #d1d5db;
    border-radius: 7px;

    background: #ffffff;

    font-family: inherit;
    font-size: 14px;
    color: #111827;

    outline: none;

    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}


.operation-edit-panel .form-field textarea {
    min-height: 90px;
    resize: vertical;
}


.operation-edit-panel .form-field input:focus,
.operation-edit-panel .form-field select:focus,
.operation-edit-panel .form-field textarea:focus {
    border-color: #28704d;

    box-shadow:
        0 0 0 3px
        rgba(40, 112, 77, 0.10);
}


.operation-edit-panel .form-field-full {
    grid-column: 1 / -1;
}


.operation-edit-panel .form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;

    gap: 10px;

    padding-top: 6px;
}


.operation-edit-panel .form-actions .btn-primary,
.operation-edit-panel .form-actions .btn-secondary {
    min-width: 125px;
    text-align: center;
}


@media (max-width: 800px) {

    .operation-edit-panel .form-grid {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .operation-edit-panel .form-field-full {
        grid-column: auto;
    }

    .operation-edit-panel .form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .operation-edit-panel .form-actions .btn-primary,
    .operation-edit-panel .form-actions .btn-secondary {
        width: 100%;
    }

}


/* Estado cancelado más visible */

.status-cancelled {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-weight: 700;
}

.row-cancelled {
    background: #fafafa;
    opacity: 0.72;
}


/* =========================================================
   PRODUCCION - CAPTURA POR CAJAS
   ========================================================= */

.production-calculated-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.production-calculated-field input {
    flex: 1;
    background: #f8faf9 !important;
    font-weight: 600;
}

.production-calculated-field span {
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    color: #667085;
}

.production-factor-message {
    min-height: 18px;
    font-size: 12px;
    color: #667085;
}

.production-factor-message.error {
    color: #b42318;
    font-weight: 600;
}


/* =========================================================
   SWITCH UNIDAD DE PRODUCCION
   ========================================================= */

.production-unit-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.production-unit-label {
    font-size: 13px;
    font-weight: 600;
    color: #667085;
}

.production-unit-switch {
    display: inline-flex;
    padding: 3px;
    border: 1px solid #d0d5dd;
    border-radius: 9px;
    background: #ffffff;
}

.production-unit-btn {
    min-width: 82px;
    padding: 7px 14px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: #475467;

    font-family: inherit;
    font-size: 13px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease;
}

.production-unit-btn:hover {
    background: #f2f4f7;
}

.production-unit-btn.active {
    background: #17633f;
    color: #ffffff;
}

.kpi-unit {
    margin-top: 3px;
    font-size: 11px;
    color: #667085;
}


@media (max-width: 700px) {

    .production-unit-toolbar {
        justify-content: space-between;
    }

    .production-unit-btn {
        min-width: 70px;
    }

}


/* =========================================================
   AGRUPACION TEMPORAL DE PRODUCCION
   ========================================================= */

.production-period-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.production-unit-toolbar {
    flex-wrap: wrap;
    gap: 18px;
}

@media (max-width: 900px) {

    .production-unit-toolbar {
        justify-content: flex-start;
    }

    .production-period-selector {
        width: 100%;
        justify-content: space-between;
    }

}


/* ==========================================================
   USUARIOS
   ========================================================== */

.users-new-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 132px;
    min-height: 40px;

    padding: 9px 18px;

    border-radius: 8px;

    white-space: nowrap;
    text-decoration: none;
}


/* ==========================================================
   RESPONSIVE MOVIL - NAVEGACION
   ========================================================== */

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mobile-menu-button {
    display: none;
}

.sidebar-overlay {
    display: none;
}


@media (max-width: 800px) {

    body {
        overflow-x: hidden;
    }

    body.mobile-menu-open {
        overflow: hidden;
    }


    /* ------------------------------------------------------
       TOPBAR
       ------------------------------------------------------ */

    .topbar {
        position: sticky;
        top: 0;
        z-index: 1100;

        width: 100%;

        padding: 10px 14px;

        flex-direction: column;
        align-items: stretch;

        gap: 10px;

        background: #ffffff;

        border-bottom:
            1px solid #e5e7eb;
    }


    .topbar-left {
        width: 100%;

        display: flex;
        align-items: center;

        gap: 10px;
    }


    .brand {
        min-width: 0;
        flex: 1;

        gap: 10px;
    }


    .company-logo {
        width: 48px;
        height: 48px;
    }


    .brand-title {
        font-size: 16px;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    .brand-subtitle {
        font-size: 11px;
    }


    /* ------------------------------------------------------
       BOTON MENU
       ------------------------------------------------------ */

    .mobile-menu-button {
        width: 42px;
        height: 42px;

        flex-shrink: 0;

        display: inline-flex;
        flex-direction: column;

        align-items: center;
        justify-content: center;

        gap: 5px;

        padding: 0;

        border:
            1px solid #d1d5db;

        border-radius: 9px;

        background: #ffffff;

        cursor: pointer;
    }


    .mobile-menu-button span {
        display: block;

        width: 19px;
        height: 2px;

        border-radius: 2px;

        background: #374151;
    }


    /* ------------------------------------------------------
       USUARIO / EMPRESA
       ------------------------------------------------------ */

    .topbar-actions {
        width: 100%;

        display: grid;

        grid-template-columns:
            minmax(0, 1fr)
            auto
            auto;

        align-items: end;

        gap: 10px;
    }


    .company-selector {
        min-width: 0;
    }


    .company-selector select {
        width: 100%;
        max-width: 100%;
    }


    .user-box {
        min-width: 0;

        padding-left: 0;

        border-left: none;
    }


    .user-name {
        max-width: 130px;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }


    .logout-link {
        white-space: nowrap;
    }


    /* ------------------------------------------------------
       APP
       ------------------------------------------------------ */

    .app-shell {
        display: block;

        min-height:
            calc(100vh - 110px);
    }


    .main-content {
        width: 100%;

        min-width: 0;

        padding:
            18px 14px 28px;
    }


    /* ------------------------------------------------------
       SIDEBAR DRAWER
       ------------------------------------------------------ */

    .sidebar {
        position: fixed;

        top: 0;
        left: 0;
        bottom: 0;

        z-index: 1300;

        width: min(
            82vw,
            300px
        );

        height: 100vh;

        padding:
            84px 14px 24px;

        overflow-y: auto;

        border-right:
            1px solid #e5e7eb;

        border-bottom: none;

        background: #ffffff;

        box-shadow:
            10px 0 30px
            rgba(15, 23, 42, 0.14);

        transform:
            translateX(-105%);

        transition:
            transform 0.22s ease;
    }


    .sidebar.mobile-open {
        transform:
            translateX(0);
    }


    .sidebar-overlay {
        position: fixed;

        inset: 0;

        z-index: 1200;

        display: block;

        visibility: hidden;
        opacity: 0;

        background:
            rgba(15, 23, 42, 0.38);

        transition:
            opacity 0.20s ease,
            visibility 0.20s ease;
    }


    .sidebar-overlay.show {
        visibility: visible;
        opacity: 1;
    }


    /* ------------------------------------------------------
       CONTENIDO EJECUTIVO
       ------------------------------------------------------ */

    .page-header {
        margin-bottom: 18px;
    }


    .page-header h1 {
        font-size: 22px;
    }


    .page-header p {
        font-size: 13px;
    }


    .panel {
        min-width: 0;
    }


    .chart-container {
        height: 300px;

        padding:
            14px 10px 18px;
    }


    .weekly-chart-large {
        height: 340px;
    }


    .project-chart {
        height: 310px;
    }


    .table-responsive {
        max-width: 100%;

        overflow-x: auto;

        -webkit-overflow-scrolling:
            touch;
    }

}


@media (max-width: 520px) {

    .main-content {
        padding:
            14px 10px 24px;
    }


    .topbar {
        padding:
            9px 10px;
    }


    .company-logo {
        width: 42px;
        height: 42px;
    }


    .brand-title {
        font-size: 15px;
    }


    .brand-subtitle {
        display: none;
    }


    .topbar-actions {
        grid-template-columns:
            minmax(0, 1fr)
            auto;
    }


    .user-box {
        display: none;
    }


    .chart-container {
        height: 270px;
    }


    .weekly-chart-large {
        height: 300px;
    }


    .project-chart {
        height: 280px;
    }


    .kpi-card {
        padding: 16px;
    }


    .kpi-value {
        font-size: 22px;
    }

}

/* ==========================================================
   DASHBOARD EJECUTIVO - DIRECTOR
   ========================================================== */

.director-kpi-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 24px;
}

.director-primary-kpi {
    border:
        2px solid #245c43;

    background: #f5faf7;
}

.director-primary-kpi .kpi-value {
    color: #245c43;
}

.director-cost-kpi .kpi-value {
    color: #245c43;
}


@media (max-width: 1050px) {

    .director-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 520px) {

    .director-kpi-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));

        gap: 10px;

        margin-bottom: 16px;
    }

    .director-kpi-grid .kpi-card {
        padding: 14px 12px;
    }

    .director-kpi-grid .kpi-label {
        margin-bottom: 6px;
        font-size: 11px;
    }

    .director-kpi-grid .kpi-value {
        font-size: 20px;
    }

    .director-kpi-grid .kpi-subtext {
        font-size: 10px;
    }

}


/* ==========================================================
   FILTROS DASHBOARD EJECUTIVO
   ========================================================== */

.dashboard-executive-filters {
    margin-bottom: 18px;

    padding: 16px;

    background: #ffffff;

    border:
        1px solid #e5e7eb;

    border-radius: 12px;
}


.dashboard-filter-form {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr))
        auto;

    gap: 14px;

    align-items: end;
}


.dashboard-filter-field {
    min-width: 0;
}


.dashboard-filter-field label {
    display: block;

    margin-bottom: 6px;

    font-size: 11px;
    font-weight: 600;

    color: #667085;
}


.dashboard-filter-field select {
    width: 100%;
}


.dashboard-filter-actions {
    display: flex;

    gap: 8px;

    align-items: center;
}


@media (max-width: 800px) {

    .dashboard-filter-form {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }


    .dashboard-filter-actions {
        grid-column:
            1 / -1;

        justify-content: flex-end;
    }

}


@media (max-width: 520px) {

    .dashboard-executive-filters {
        padding: 12px;

        margin-bottom: 14px;
    }


    .dashboard-filter-form {
        grid-template-columns:
            1fr;
    }


    .dashboard-filter-actions {
        grid-column: auto;

        display: grid;

        grid-template-columns:
            1fr 1fr;
    }


    .dashboard-filter-actions
    .btn-primary,

    .dashboard-filter-actions
    .btn-secondary {
        width: 100%;

        text-align: center;
    }

}


/* ==========================================================
   CONTEXTO DE FILTROS - DASHBOARD EJECUTIVO
   ========================================================== */

.dashboard-filter-context {
    display: flex;
    flex-wrap: wrap;

    align-items: center;

    gap: 6px;

    margin-top: 8px;

    font-size: 13px;
    font-weight: 600;

    color: #245c43;
}


.dashboard-filter-context span {
    color: #98a2b3;
    font-weight: 400;
}


@media (max-width: 520px) {

    .dashboard-filter-context {
        margin-top: 6px;

        font-size: 12px;
    }

}


/* ==========================================================
   NOMINA ADMINISTRATIVA
   ========================================================== */

.admin-payroll-summary-grid {
    display: grid;

    grid-template-columns:
        repeat(4, minmax(0, 1fr));

    gap: 16px;

    margin-bottom: 22px;
}


.admin-payroll-section {
    margin-bottom: 22px;
}


.admin-payroll-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}


.admin-payroll-link-button {
    display: inline-flex;

    align-items: center;
    justify-content: center;

    text-decoration: none;
}


.admin-payroll-calculate {
    display: flex;

    justify-content: flex-end;

    padding: 18px 20px;
}


.admin-payroll-modal {
    max-width: 760px;
}


@media (max-width: 800px) {

    .admin-payroll-summary-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 600px) {

    .admin-payroll-page-header {
        gap: 14px;
    }


    .admin-payroll-header-actions {
        width: 100%;

        display: grid;

        grid-template-columns:
            1fr 1fr;
    }


    .admin-payroll-header-actions
    .btn-primary,

    .admin-payroll-header-actions
    .btn-secondary {
        width: 100%;
    }


    .admin-payroll-summary-grid {
        gap: 10px;
    }


    .admin-payroll-summary-grid
    .kpi-card {
        padding: 14px 12px;
    }


    .admin-payroll-summary-grid
    .kpi-value {
        font-size: 20px;
    }

}


/* ==========================================================
   RESUMEN NOMINA ADMINISTRATIVA
   ========================================================== */

.admin-summary-total-row td {
    background: #f8faf9;

    border-top:
        2px solid #dbe5df;

    font-size: 14px;
}


/* ==========================================================
   COSTOS - DESGLOSE EN TRES AREAS
   ========================================================== */

.cost-breakdown-grid {
    grid-template-columns:
        repeat(3, minmax(0, 1fr));
}


@media (max-width: 1100px) {

    .cost-breakdown-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

}


@media (max-width: 700px) {

    .cost-breakdown-grid {
        grid-template-columns:
            1fr;
    }

}

.dev-environment-banner {
    width: 100%;
    padding: 6px 12px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: #fff3cd;
    color: #664d03;
    border-bottom: 1px solid #ffecb5;
    position: relative;
    z-index: 9999;
}
