body { font-family: Arial, sans-serif; padding: 20px; background-color: #f4f4f9; margin: 0; }
.card { background: white; padding: 20px; border-radius: 8px; max-width: 1050px; margin: 0 auto; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.card-sm { max-width: 380px; }
input, select, button { width: 100%; margin-bottom: 10px; padding: 10px; box-sizing: border-box; border-radius: 4px; border: 1px solid #ccc; font-size: 13px; }
button { background-color: #2563eb; color: white; border: none; cursor: pointer; font-weight: bold; }
button:hover { background-color: #1d4ed8; }

.btn-volver { background-color: #6b7280; width: auto; margin-bottom: 15px; }
.btn-guardar { background-color: #10b981; margin-top: 20px; font-size: 15px; }
.btn-danger { background-color: #dc2626; width: auto; }
.btn-sm { width: auto; padding: 5px 10px; font-size: 12px; margin-bottom: 0; }
.btn-abrir { background-color: #10b981; }
.btn-cerrar { background-color: #f59e0b; }
.btn-excel { background-color: #059669; width: auto; margin-bottom: 0; }
.btn-pdf { background-color: #dc2626; color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; margin-right: 5px; font-weight: bold; }
.btn-eliminar { background-color: #ef4444; color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; }
.btn-editar { background-color: #f59e0b; color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; margin-right: 5px; }
.btn-ok { background-color: #10b981; color: white; border: none; padding: 4px 8px; border-radius: 4px; cursor: pointer; font-size: 11px; margin-right: 5px; }

.oculto { display: none !important; }

.contenedor-tabla { overflow-x: auto; margin-top: 15px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border: 1px solid #d1d5db; padding: 8px; text-align: center; vertical-align: middle; }
th { background-color: #f3f4f6; color: #1f2937; }
.th-izq { text-align: left; }

.badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: bold; text-transform: uppercase; margin-top: 3px; }
.badge-abierto { background-color: #d1fae5; color: #065f46; }
.badge-cerrado { background-color: #fee2e2; color: #991b1b; }
.badge-nivel { background-color: #e0e7ff; color: #4338ca; margin-left: 10px; }

.celda-periodo { display: flex; gap: 4px; justify-content: center; align-items: center; }
.input-num { width: 42px; padding: 4px; text-align: center; border: 1px solid #ccc; border-radius: 4px; font-size: 12px; margin-bottom: 0; }
.input-num:disabled { background-color: #e5e7eb; color: #6b7280; cursor: not-allowed; }
.input-f { border-color: #fca5a5; }

.promedio-final { font-weight: bold; font-size: 14px; color: #1d4ed8; }
.promedio-pendiente { color: #9ca3af; font-style: italic; font-weight: normal; }

.grid-admin { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; }
@media (max-width: 768px) { .grid-admin { grid-template-columns: 1fr; } }
.box-admin { border: 1px solid #e5e7eb; padding: 15px; border-radius: 6px; background-color: #f9fafb; }
.box-admin-full { margin-top: 20px; border: 1px solid #e5e7eb; padding: 15px; border-radius: 6px; background-color: #f9fafb; }

.admin-tabs { display: flex; gap: 10px; margin-bottom: 20px; border-bottom: 2px solid #e5e7eb; padding-bottom: 10px; flex-wrap: wrap; }
.tab-btn { background: none; color: #6b7280; border: none; font-weight: bold; font-size: 14px; cursor: pointer; padding: 8px 16px; width: auto; border-radius: 0; }
.tab-btn:hover { background: #f3f4f6; }
.tab-btn.active { color: #2563eb; border-bottom: 3px solid #2563eb; }
.admin-section { display: none; }
.admin-section.active { display: block; }


/* ==============================================
   ESTILOS PARA LA BOLETA (MOTOR NATIVO DEL NAVEGADOR)
   ============================================== */
.boleta-papel {
    width: 100%;
    max-width: 800px;
    background: white;
    padding: 40px;
    font-family: Arial, sans-serif;
    color: #000;
    position: relative;
    box-sizing: border-box;
    margin: 0 auto;
}
.boleta-marca-agua {
    position: absolute;
    top: 25%; left: 15%; width: 70%; height: 50%;
    background-image: url('logo.png'); /* Usa tu logo local */
    background-size: contain; background-repeat: no-repeat; background-position: center;
    opacity: 0.08; z-index: 1;
}
.boleta-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; z-index: 2; position: relative; }
.boleta-logo { width: 250px; height: auto; }
.boleta-titulos { text-align: right; }
.boleta-titulos h1, .boleta-titulos h2, .boleta-titulos h3 { margin: 0; color: #1a3e8a; } /* AZUL INSTITUCIONAL */
.boleta-titulos h1 { font-size: 24px; font-weight: bold; }
.boleta-titulos h2 { font-size: 16px; font-weight: normal; }
.boleta-titulos h3 { font-size: 14px; margin-top: 10px; }
.boleta-titulos p { margin: 5px 0 0 0; font-size: 11px; color: #000; }

.boleta-datos { margin-bottom: 30px; font-size: 14px; z-index: 2; position: relative; text-transform: uppercase; }
.dato-label { font-weight: bold; margin-right: 5px; }
.dato-valor { display: inline-block; border-bottom: 1px solid #000; padding-bottom: 2px; }
.boleta-dato-fila { margin-bottom: 15px; display: flex; align-items: flex-end; }
.boleta-dato-fila .dato-valor { flex-grow: 1; margin-left: 5px; }
.boleta-dato-grid { display: flex; justify-content: space-between; align-items: flex-end; }
.boleta-dato-grid > div { display: flex; align-items: flex-end; }
.boleta-dato-grid .dato-valor { min-width: 120px; margin-left: 5px; text-align: center; }

/* TABLA Y NÚMEROS (Forzados a negro para que no desaparezcan) */
.boleta-tabla { 
    width: 100%; 
    border-collapse: collapse; 
    z-index: 2; 
    position: relative; 
    font-size: 13px; 
    color: #000 !important; /* Fuerza los números a color negro */
}
.boleta-tabla th, .boleta-tabla td { 
    border: none; 
    padding: 6px 2px; 
    text-align: center; 
    vertical-align: middle; 
    color: #000 !important; 
}
.boleta-tabla td.td-materia, .boleta-tabla th.td-materia { 
    text-align: left; 
    padding-right: 10px; 
}
.boleta-tabla th { font-weight: normal; }
.boleta-tabla tfoot td { padding-top: 30px; font-weight: normal; }

/* TEXTO VERTICAL PURO (Perfecto para Safari/Chrome nativo) */
.texto-vertical {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    display: inline-block;
    font-size: 9px;
    height: 85px;
    text-align: left;
    margin: 0 auto;
    color: #000 !important;
}

/* ==============================================
   REGLAS DE IMPRESIÓN (MAGIA PARA GENERAR EL PDF)
   ============================================== */
@media print {
    body { background: white; margin: 0; padding: 0; }
    .card { display: none !important; } /* Oculta todo el sistema y menús */
    
    #contenedor-boleta-pdf { 
        display: block !important; position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; 
    }
    
    /* 1. ESTO ELIMINA LA URL, FECHA Y PÁGINA DEL NAVEGADOR */
    @page { size: letter portrait; margin: 0mm; }
    
    /* 2. AGREGAR MARGEN INTERNO PARA QUE NO SE CORTE EN EL PAPEL */
    .boleta-papel { width: 100%; padding: 1.5cm !important; }
    
    /* 3. FORZAR A LA IMPRESORA A IMPRIMIR EL COLOR AZUL */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
    .boleta-titulos h1, .boleta-titulos h2, .boleta-titulos h3 { color: #1a3e8a !important; }
}